0
我在Visual Studio中創建了一個C#應用程序,該應用程序託管在IIS 7.5上。直接訪問應用程序的ASPX文件會導致自動刪除其擴展名(頁面呈現正確)。禁用刪除ASPX擴展
例如,訪問以下網址時: http://www.example.com/contact.aspx
以下URL從服務器返回: http://www.example.com/contact
我想進行配置,以便訪問與它的擴展名的ASPX文件的應用程序返回包含擴展名的URL。
web.config中沒有<rewrite>
標記。
的Global.asax內容:
<%@ Application Language="C#" %>
<%@ Import Namespace="WebSite2" %>
<%@ Import Namespace="System.Web.Optimization" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
</script>
RouteConfig.cs內容:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Routing;
using Microsoft.AspNet.FriendlyUrls;
namespace WebSite2
{
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);
}
}
}
感謝。
請發表您的'Global.asax'代碼或者看看是否有你'web.config' – techspider
問題更新任何''標籤。 –
user6691195
你有沒有執行任何'RouteConfig.cs'編碼? – techspider