开发者

ASP.NET MVC in Subfolder/Virtual Directory/Routing/Domain issue

I posted the following question yesterday but didn't get a helpful answer. May i was not clear enough, i am very sorry.

After hours of searching here and googling with Bing i could not solve the following Problem. It does not should a "heavy" Problem.

here is my problem

  1. I have a Domain like http://example.com that is pointed to a virtual directory on my webspace like http://myprovider.com/VirtualDirectoryName/.

  2. The folder structure on my webspace is (off course) like this

root

 bin
 VirtualDirectoryName
     bin
     Content
     Scripts
     Views
   Web.config
   Global.asax

If i开发者_如何学JAVA call now "http://www.domain.com" i get the Site without CSS and the links are "http://www.domain.com/VirtualDirectoryName/".

I used the default and almost empty default "Internet Application". So the routing is default and all links are created with @Html.ActionLink.

Please help me, i tried so many things but i cant get it working. In my local environment i can affect that with IIS settings but (off course) i do not have access on the IIS settings of my host.

btw, my hosting provider provider is discount ASP.NET.

Thank you all!


How are you referencing the css files in your html?

If your referencing the like:

<link href="../../Content/Style.css" rel="stylesheet" type=\"text/css\" />

It might not be looking in the correct directory. Try the referencing it as the following:

<link href="/Content/Style.css" rel="stylesheet" type=\"text/css\" />

That way you reference it from the root.

A good way to check is to use the "net" tab within firebug this will show if they are loading and if not what location it is trying to find them.


Link your css and javascript this way (using ResolveClientUrl):

<link href="<%=ResolveClientUrl("/Content/style.css")%>" rel="stylesheet" type="text/css" />


The problem was a simple routing error. My Application was only a simple folder in the iis and not a virtual directory / application. After setting the folder to an application the problem is gone.


I think you can solve it using web.config at the root as suggested here How to host ASP.NET MVC site in a subfolder

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜