1

I'm running a bunch of apps on discountasp.net with the subdomain addon. Since with shared hosting I can't have multiple IIS sites, I've also written an HTTP module that allows sites in subfolders to operate as if they are running in the root directory. So for example, instead of hosting my blog at dandoes.net/blog, I can host it at blog.dandoes.net (which is really actually dandoes.net). This has been working famously until now, when I'm trying to use it along with MVC.

The HtmlHelper generates its urls based on the virtual path of the application rather than the path data in the URL. So, if I'm on blog.dandoes.net and I want to link to blog.dandoes.net/Samples, I might have this code:

<%=Html.ActionLink("Samples", "Index", "Samples")%>

In normal circumstances, this would generate the url blog.dandoes.net/Samples, but instead, it generates blog.dandoes.net/Blog/Samples because the virtual directory is /Blog.

I could probably take 5 minutes and write something really hacky to do what I want, but I think it would be really interesting if I could get the MVC framework to do what I want.

So, is there any way I could get it to render the correct urls?

4

1 回答 1

1

HTML 帮助器只是一个将字符串返回到您的代码的类。您需要做的就是编写自己的帮助程序类,以您需要的格式输出字符串。

于 2009-07-22T21:11:31.747 回答