安装 microsoft.aspnet.friendurls 以隐藏 URL 中的 .aspx 后,该网站仅在移动设备上显示 500 内部服务器错误,但在桌面上运行良好。

编程


After installing Microsoft.AspNet.FriendlyUrls to hide .aspx from URL, The website is showing 500 internal server error only on mobile devices, but it works fine on the desktop.

代码在 路由配置.cs

C#
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Routing;
using Microsoft.AspNet.FriendlyUrls;

namespace ASP
{
    public static class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            var settings = new FriendlyUrlSettings();
            settings.AutoRedirectMode = RedirectMode.Permanent;
            routes.EnableFriendlyUrls(settings);
        }
    }
}

代码在 全局.asax

网络平台
<%@ Application Language="C#" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        RouteConfig.RegisterRoutes(System.Web.Routing.RouteTable.Routes);
        // Code that runs on application startup

    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc on the Web. config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }

我尝试过的:

我在任何地方都找不到解决方案。

コメント

タイトルとURLをコピーしました