如何做网址路由..它不工作..Page没有正确显示重定向... [英] How to do Url routing..Its not working ..Page isn't redirecting correctly shown...

查看:51
本文介绍了如何做网址路由..它不工作..Page没有正确显示重定向...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

web..config

 <   system .webserver  >  
< modules runallmanagedmodulesforallrequests = true >
< 删除 名称 = UrlRoutingModule / >
< add 名称 = UrlRoutingModule 类型 = System.Web.Routing.UrlRoutingModule,System.Web,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a / >
< / modules >
< 处理程序 >
< add >
name =UrlRoutingHandler
preCondition =integratedMode
verb =*path =Ur lRouting.axd
type =System.Web.HttpForbiddenHandler,System.Web,
Version = 2.0.0.0,Culture = neutral,
PublicKeyToken = b03f5f7f11d50a3a/>
< / add > < / handlers >
< / system.webserver >



在application_start的global.asax下尝试以下代码

 RouteTable.Routes.MapPageRoute ( 类别  categories / {id} 〜/ JobReport / WebForm1。 aspx?id = longvalue); 



和页面加载页面为

 Response.RedirectToRoute(  Category new  {id =   1}); 



但页面没有正确显示重定向...

解决方案

阅读并按照这里提到的步骤:对于ASP.NET 4.0: URL路由 [ ^ ]

web..config

<system.webserver>
    <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>
    <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"/>
    </add></handlers>
  </system.webserver>


Tried the following code under global.asax of application_start

RouteTable.Routes.MapPageRoute("Category", "categories/{id}", "~/JobReport/WebForm1.aspx?id=longvalue");


and under page load of the page as

Response.RedirectToRoute("Category", new { id = "1"});


But page isn''t redirecting properly shown...

解决方案

Read about it and follow the steps mentioned here: For ASP.NET 4.0: URL Routing[^]


这篇关于如何做网址路由..它不工作..Page没有正确显示重定向...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆