简体   繁体   English

URL在asp.net 4.0中的文件夹内的页面路由?

[英]Url Routing for the page inside a folder in asp.net 4.0?

I am trying to implement Url routing in asp.net 4.0. 我正在尝试在asp.net 4.0中实现Url路由。 I just a created a small test application. 我只是创建了一个小型测试应用程序。 I am trying to browse the pages kept inside the folder. 我正在尝试浏览保存在文件夹中的页面。 It works fine when i am running in Visual studio..but when i hosted the application in IIS7 then it showed an error. 当我在Visual Studio中运行时,它可以正常工作。但是当我在IIS7中托管应用程序时,它显示了错误。

HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. HTTP错误404.0-找不到所需的资源已被删除,名称已更改或暂时不可用。

The code i used is. 我使用的代码是。 (i am using master page too.) (我也在使用母版页。)

protected void Application_Start(object sender, EventArgs e)
    {
        CustomRouteTable(RouteTable.Routes);
    }

 void CustomRouteTable(RouteCollection routes)
    {
        routes.MapPageRoute("Telugu", "Movie/Telugu", "~/Telugu/Telugu.aspx");

    }

in my default.aspx page i kept a button and on click of the button i wrote. 在我的default.aspx页面中,我保留了一个按钮,并单击了我写的按钮。

protected void btnTelugu_Click(object sender, ImageClickEventArgs e)
        {
            Response.RedirectToRoute("Telugu");
        }

where am i going wrong??? 我要去哪里错了??? Thanks. 谢谢。

protected void btnTelugu_Click(object sender, ImageClickEventArgs e)
{
    Response.RedirectToRoute("Movie/Telugu");
}

Have you updated your web.config to support URL Routing on IIS7. 您是否更新了web.config以支持IIS7上的URL路由。

<system.webServer>
   <modules runAllManagedModulesForAllRequests="true">

      <add name="UrlRoutingModule"
             type="System.Web.Routing.UrlRoutingModule, 
                   System.Web.Routing, Version=3.5.0.0, 
                   Culture=neutral, 
                   PublicKeyToken=31BF3856AD364E35" />
      <!-- ... -->

    </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" />
      <!-- ... -->

    </handlers>
</system.webServer>

Here is the artice where I c/p the example from, that will give you more details. 这是我摘自示例的文章,它将为您提供更多详细信息。

http://msdn.microsoft.com/en-us/magazine/dd347546.aspx http://msdn.microsoft.com/zh-CN/magazine/dd347546.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM