【问题标题】:Url Route HTML not rendering网址路由 HTML 未呈现
【发布时间】:2014-01-05 12:20:16
【问题描述】:

我曾经使用过 Url Route,但有时我觉得 HTML 代码没有呈现

这是我在 Global.asax

中的代码
void Application_Start(object sender, EventArgs e)
{   
    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routeCollection)
{
    routeCollection.MapPageRoute("LogIn", "logga-in", "~/Login.aspx");
    routeCollection.MapPageRoute("Contact", "kontakt", "~/Contact.aspx");
    routeCollection.MapPageRoute("About", "om", "~/About.aspx");
    routeCollection.MapPageRoute("Job", "jobb", "~/Job.aspx");
    routeCollection.MapPageRoute("Connect", "anslut", "~/Connect.aspx");
    routeCollection.MapPageRoute("Default", "", "~/Default.aspx");
    routeCollection.MapPageRoute("Booking", "bokning/{Id}", "~/Booking.aspx");

    routeCollection.MapPageRoute("DashboardDefault", "panel/", "~/Dashboard/Default.aspx");
    routeCollection.MapPageRoute("DashboardAbout", "panel/om", "~/Dashboard/About.aspx");
    routeCollection.MapPageRoute("DashboardContact", "panel/kontakt", "~/Dashboard/Contact.aspx");
    routeCollection.MapPageRoute("DashboardLogIn", "panel/logga-in", "~/Dashboard/Login.aspx");
}

访问 aspx 网站时,一切都很好,例如 http://www.dentalo.se/dashboard/login.aspx 下图

尝试访问同一页面,但使用友好的 url,而不是 http://www.dentalo.se/panel/logga-in 它看起来像这样。

谁能帮助我为什么会发生这种情况?我确定 javascript 也没有呈现。

【问题讨论】:

    标签: html asp.net asp.net-mvc webforms


    【解决方案1】:

    您的 css 样式表未加载。发生这种情况是因为重写并且浏览器尝试从路径/panel/assets/... 加载文件使用绝对路径使事情正常工作。

    <link href="/dashboard/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="/dashboard/assets/css/metro.css" rel="stylesheet" />
    ...
    

    【讨论】:

    • 好的,我明白了。非常感谢我的朋友。
    • 很高兴您发现我的回答很有帮助
    猜你喜欢
    • 2023-04-07
    • 2018-08-03
    • 2016-11-19
    • 1970-01-01
    • 1970-01-01
    • 2017-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多