Asp.net Web表单URL路由404错误 [英] Asp.net web forms URL routing 404 error
问题描述
您好,
我有一个asp.net网络表单应用程序,需要添加网址路由。
已经关注 MSDN [ ^ ]。
我还添加了< modules runAllManagedModulesForAllRequests =true>到web.config。
总是返回 HTTP错误404.0 - 未找到
我已经在网上看了很多并尝试了所有可能的解决方案好运
请指教
提前致谢!!
Samira < br $> b $ b
我的尝试:
全球.asax.cs
Hello,
I have an asp.net web form application and need to add url routing.
Had followed MSDN[^].
I have also added <modules runAllManagedModulesForAllRequests="true" > into web.config.
always return HTTP Error 404.0 - Not Found
I have looked on-line alot and tried all possible solutions with no luck
Please advise
Thanks in advance!!
Samira
What I have tried:
Global.asax.cs
protected void Application_Start(object sender, EventArgs e)
{
urlRouting(RouteTable.Routes);
}
void urlRouting(RouteCollection routes)
{
routes.MapPageRoute("IC", "IC", "~/EN/en-ic.aspx");
routes.MapPageRoute("brands", "brands", "~/EN/brands.aspx");
}
在母版页中分配href
assign href in master page
if (Page.User.Identity.IsAuthenticated)
{
brands_li.HRef = "brands";
li_IC.HRef = "IC";
}
web.config
web.config
<!-- routing -->
<modules runAllManagedModulesForAllRequests="true" >
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<!--end of routing-->
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
推荐答案
你能在下面试试吗?
Could you try below -
//Global.asax
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("IC", "IC", "~/Page1.aspx");
}
链接为 -
Have your link as -
<asp:LinkButton ID="lnkLC" runat="server" OnClick="lnkLC_Click">IC_PAGE_TEST</asp:LinkButton>
然后将您的活动设为 -
and then have your event as -
protected void lnkLC_Click(object sender, EventArgs e)
{
Response.RedirectToRoute("IC");
}
您找到了解决方案吗?我现在也有同样的问题。
Did you ever find a solution? I have the same issue right now.
这篇关于Asp.net Web表单URL路由404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!