Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何绘制路线图http://localhost:53244/page.aspx?ID=7842 到http://localhost:53244/Home_C#_Asp.net_.net_Routing - Fatal编程技术网

C# 如何绘制路线图http://localhost:53244/page.aspx?ID=7842 到http://localhost:53244/Home

C# 如何绘制路线图http://localhost:53244/page.aspx?ID=7842 到http://localhost:53244/Home,c#,asp.net,.net,routing,C#,Asp.net,.net,Routing,需要映射路由,例如到,并且需要在新映射的URL中传递默认查询字符串 我已经尝试过System.Web.Routing.RouteTable.Routes.MapPageRoute(“Home”、“Home”、“Page.aspx”、false、newRouteValueDictionary{{{“ID”、“7844}”) 但它对我不起作用,因为我需要request.querystring中的id,而不是Page.RouteData.Values[“id”] 这是我的基本代码System.Web.

需要映射路由,例如到,并且需要在新映射的URL中传递默认查询字符串

我已经尝试过
System.Web.Routing.RouteTable.Routes.MapPageRoute(“Home”、“Home”、“Page.aspx”、false、newRouteValueDictionary{{{“ID”、“7844}”)
但它对我不起作用,因为我需要request.querystring中的id,而不是
Page.RouteData.Values[“id”]

这是我的基本代码
System.Web.Routing.RouteTable.Routes.MapPageRoute(“Home”,“Home/{*queryvalues}”,“~/Page.aspx”,false)

在其中,我可以像使用url一样使用url,但我只需要使用Web.Config就可以使用url映射

 <system.web> 
    <urlMappings enabled="true">
      <add
          url="~/page.aspx?ID=.."
          mappedUrl="~/Home" />  
  </system.web>

要处理page.aspx返回的所有页面,可以使用url重写规则

<rewriteModule>
  <rewriteOn>true</rewriteOn>
  <rewriteRules>
      <rule source="(.*)/Home"  
         destination="page.aspx?ID=$1"/> 
  </rewriteRules>
</rewriteModule>

真的