asp.net mvc路由无法正常工作\ 404 - 找不到文件或目录。部署后在本地工作不工作

时间:2013-03-04 19:01:33

标签: asp.net asp.net-mvc asp.net-mvc-3 web-services web-config

我的webconfig asp.net mvc路由无法正常工作\ 404 - 找不到文件或目录。在部署后工作本地不工作请检查我的代码是这个webconfig。错误

 <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=152368
      -->
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
      </configSections>

      <appSettings>
        <add key="webpages:Version" value="1.0.0.0"/>
        <add key="ClientValidationEnabled" value="true"/>
        <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
      </appSettings>
      <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true" targetFramework="4.0"/>
        <authentication mode="Forms">
          <forms loginUrl="~/Account/LogOn" timeout="2880"/>
        </authentication>
        <pages controlRenderingCompatibilityVersion="4.0">
          <namespaces>
            <add namespace="System.Web.Helpers"/>
            <add namespace="System.Web.Mvc"/>
            <add namespace="System.Web.Mvc.Ajax"/>
            <add namespace="System.Web.Mvc.Html"/>
            <add namespace="System.Web.Routing"/>
            <add namespace="System.Web.WebPages"/>
          </namespaces>
        </pages>
        <httpRuntime/>
        <profile defaultProvider="DefaultProfileProvider">
          <providers>
            <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/>
          </providers>
        </profile>
        <membership defaultProvider="DefaultMembershipProvider">
          <providers>
            <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
          </providers>
        </membership>
        <roleManager defaultProvider="DefaultRoleProvider">
          <providers>
            <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/>
          </providers>
        </roleManager>
        <sessionState mode="InProc" customProvider="DefaultSessionProvider">
          <providers>
            <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection"/>
          </providers>
        </sessionState>
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0"/>
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
      <connectionStrings>
        <!--<add name="strConn" connectionString="Data Source=localhost;Initial Catalog=F;Integrated Security=false;User ID=aghamoeez;Password=harry580" />-->
        <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WMF-20130221092444;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WMF-20130221092444.mdf"/>
      </connectionStrings>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <handlers>
          <remove name="UrlRoutingHandler"/>
        </handlers>

      </system.webServer>
    </configuration>

Gloab.asax 文件代码检查mu routing这里我不知道为什么要获得404 errio

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace WMF
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");




            routes.MapRoute(
            "join_us.html", // Route name
            "join_us.html", // URL with parameters
            new { controller = "Contact", action = "JoinUs", id = UrlParameter.Optional } // Parameter defaults
        );

            routes.MapRoute(
            "place_job.html", // Route name
            "place_job.html", // URL with parameters
            new { controller = "Contact", action = "PlaceJob", id = UrlParameter.Optional } // Parameter defaults
        );


            routes.MapRoute(
         "find_jobs.html", // Route name
         "find_jobs.html", // URL with parameters
         new { controller = "Contact", action = "FindJobs", id = UrlParameter.Optional } // Parameter defaults
     );
            routes.MapRoute(
     "about_us.html", // Route name
     "about_us.html", // URL with parameters
     new { controller = "Contact", action = "AboutUs", id = UrlParameter.Optional } // Parameter defaults
 );

            routes.MapRoute(
"support.html", // Route name
"support.html", // URL with parameters
new { controller = "Contact", action = "Support", id = UrlParameter.Optional } // Parameter defaults
);
            routes.MapRoute(
     "people.html", // Route name
     "people.html", // URL with parameters
     new { controller = "Contact", action = "People", id = UrlParameter.Optional } // Parameter defaults
 );


            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );


        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
        }
    }
}

0 个答案:

没有答案