Microsoft.AspNet.FriendlyUrls 404.0 - 未找到

时间:2018-06-12 15:04:47

标签: asp.net webforms routing .net-4.5 friendly-url

我通过vs 2013 Webforms.Framework 4.5运行我的项目。我使用Microsoft.AspNet.FriendlyUrls库我第一次尝试,我尝试了一切,但没有成功。我不知道问题出在哪里。我在示例中尝试了相同的代码,我尝试了不同的代码,但它不起作用。

我的Global.asax

 public class Global : NinjectHttpApplication
{
    protected void Application_Start(object sender, EventArgs e)
    {
        RouteConfig.RegisterRoutes(RouteTable.Routes);
    }



    protected void Application_Error(object sender, EventArgs e)
    {
        var httpException = Server.GetLastError() as HttpException;
        if (httpException != null && httpException.GetHttpCode() != 404)
        {
            typeof(CustomErrorHandler).ToString();
            (new CustomErrorHandler()).Process(Context);
            Response.End();
        }
    }
    protected override void OnApplicationStarted()
    {
        base.OnApplicationStarted();
        BundleTable.EnableOptimizations = FrSettings.Settings.BundleJsAndCss;
        BundleConfig.CssBundle();
        BundleConfig.JsBundle();
    }
    protected override IKernel CreateKernel()
    {
        return IoC.Container;
    }
}

我的网络配置文件:

<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="Glav.CacheAdapter.MainConfig" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
    <section name="FrSettings" type="VDershane.Base.WebForms.Configuration.FrSettings,VDershane.Base" />
    <section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
  </configSections>
  <appSettings>
    <!--Cache Timespan süresi-->
    <add key="CacheTimeSpan" value="24" />
    <!--Cache Timespan süresi-->
  </appSettings>
  <FrSettings configSource="Yaz.config" />
  <connectionStrings configSource="ConnectionStrings.config" />
  <system.web>
    <httpHandlers>
      <add path="yazfr.ashx" verb="*" type="VDershane.Base.WebForms.Handler.YazFrHandler,VDershane.Base" />
      <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
    </httpHandlers>
    <sessionState timeout="20"></sessionState>
    <globalization culture="auto" uiCulture="auto" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <customErrors mode="Off" />

  </system.web>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
        <add name="X-Frame-Options" value="SAMEORIGIN" />
        <add name="X-XSS-Protection" value="1" />
      </customHeaders>
    </httpProtocol>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <add name="frhandler" path="yazfr.ashx" verb="*" type="VDershane.Base.WebForms.Handler.YazFrHandler,VDershane.Base" />
      <add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" />
    </handlers>
    <staticContent>
      <remove fileExtension=".woff" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
    </staticContent>

  </system.webServer>
  <dotless minifyCss="false" cache="true" web="false" strictMath="false" />
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

这是我的班级:

public static class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        var settings = new FriendlyUrlSettings();
        settings.AutoRedirectMode = RedirectMode.Permanent;
        routes.EnableFriendlyUrls(settings);
        routes.MapPageRoute("", "HomePage", "~/Default.aspx");

请帮帮我,我真的很生气。我的default.aspx文件路径是

  

C:\ Users \ alican \ Documents \ Visual Studio 2013 \ Projects \ DataRecovery \ DataRecovery.UI \ Default.aspx

0 个答案:

没有答案