开发者

ASP.net: Moved from WebApp to Web Site, problem with URLs

Moved from a Web Application to a Web Site, began moving code over... and now I have a very strange problem. First and foremost, my root /Website1/ shows up when I first run the web site:

http://localhost/Website1/Default.aspx

But if I go to a sub menu option, all my URLs are set to http://localhost/SubMenuOption.aspx, thus not finding my pages. It seems that ~/SubMenuOption.aspx does not work.

Also, JS files are linking strangely. On a page inside a folder, I cannot seem to link to the root folder JS folder.

<script src="../js/jquery.js" /> 

This should go down a folder, but it doesn't. It actually inherits the folder name I'm in so if... http://localhost/Website1/Common/Sub.aspx then the JS file shows up as http://localhost/Website1/Common/js/jquery.js

The file is actually in http://localhost/Website1/js/jquery.js

It doesn't matter what I do to the script src whether it be runat="server" and ~/ or /js/ or anything, it always 开发者_C百科comes out with the folder. What is the problem here? Is this some sort of setting problem?


Resolve your links from the root like this:

<a href="~/SubMenuOption.aspx" id="link1" runat="server">Menu Item 1</a>

Be sure to include the above attributes; the runat attribute is needed for the link to be resolved server-side.

Try ResolveURL() method embedded for your script link.


Sure you hope you meant you have moved from a website to a web application?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜