问题描述
我上传了一个网站到服务器,我使用.Net 4.0中的新网址路由功能,它在我的本地机器上运行良好,但我上传到服务器时遇到问题,错误信息是:
不能使用前导..退出顶级目录
i尝试使用resolveUrl但没有成功!下面是我的代码:
全局asax文件中的
:
i uploaded a website to server, iam using the new url routing functionality in .Net 4.0, it works well on my local machine, but i am having issues when uploaded to server, th error message is:
Cannot use a leading .. to exit above the top directory
i tried using resolveUrl but no success! bellow is my code:
in the global asax file:
void RegisterRoutes ( RouteCollection routes )
{
routes.MapPageRoute("HomeRoute", "news-headline", "~/Default.aspx");
routes.MapPageRoute("DescriptionRoute", "headlinenews/{n}", "~/1111.aspx");
routes.MapPageRoute("RelatesPostRoute", "headlinenews/{n}", "~/1212.aspx");
routes.MapPageRoute("searchRoute", "search/{n}", "~/Category/SearchResults.aspx");
routes.MapPageRoute("authorRoute", "author/{n}", "~/1313.aspx");
routes.MapPageRoute("NewsRoute", "news", "~/News.aspx");
}
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
在.aspx文件中:
In the .aspx file:
<a href='<%:ResolveUrl("~/author/allAfrica") %>'>
<a href='headlinenews/<%#Eval("urlFriendlyTitle")%>'><%#Eval("title") %></a>
请知道如何解决这个问题?在此先感谢
please any idea on how to fix this? Thanks in advance
推荐答案
~/
eg ..
eg..
<script type="text/javascript" src="~/js/jquery.js"></script>
i假设您的链接和网址采用此格式所以你需要改变上面的链接
i assume your link and url in this format so you need to change above link
<img src="../img/payment-paypal.jpg" alt="payment" /></li>
祝你有个美好的一天
have a good day
这篇关于ASP.NET Routing With无法使用前导..退出顶级目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!