【问题标题】:asp.net web forms URL routing doesn't map to the physical fileasp.net Web 表单 URL 路由未映射到物理文件
【发布时间】:2015-02-08 21:56:29
【问题描述】:

我有一个使用 URL 路由的 asp.net Web 表单网站 问题是当我尝试导航到匹配的路线时,例如“http://localhost:51878/brand/adidas”它不会打开指定的 aspx 文件它显示 HTTP 错误 404.0 - 未找到并导航到 D:\Websites\Website\brand\adidas

更新:我尝试在 global.asax.cs 文件中添加断点,显然它甚至没有通过 Application_Start 函数

这是我的 global.asax`

<%@ Application Language="C#" CodeBehind="Global.asax.cs" %>

这是我的 global.asax.cs

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;
using System.Data;
using System.Data.SqlClient;


    public partial class Global : HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {


            RegisterRoutes(RouteTable.Routes);
        }

        protected void RegisterRoutes(RouteCollection routes)
        {
            routes.MapPageRoute("brandsRoute", "brand/{brand}", "~/brand.aspx");
        }

    }

你能告诉我我做错了什么

【问题讨论】:

    标签: asp.net webforms url-routing global-asax


    【解决方案1】:

    您发布的代码看起来不错,除了您的 using 语句下的错误 > 字符,这可能导致您的代码无法构建,并且您可能正在运行最后一个良好的构建版本,其中不包含您的新版本路线。

    【讨论】:

      猜你喜欢
      • 2012-11-23
      • 2011-02-19
      • 2015-12-26
      • 1970-01-01
      • 2019-01-05
      • 2016-03-22
      • 1970-01-01
      • 2012-07-21
      • 1970-01-01
      相关资源
      最近更新 更多