Iis 7 MVC5应用程序在IIS 7中不工作-错误404-找不到文件或目录
那里 经过一些来来往往,我终于在我的开发机器上运行了我的第一个MVC应用程序 情况如下:Iis 7 MVC5应用程序在IIS 7中不工作-错误404-找不到文件或目录,iis-7,asp.net-mvc-5,Iis 7,Asp.net Mvc 5,那里 经过一些来来往往,我终于在我的开发机器上运行了我的第一个MVC应用程序 情况如下: 这是一个内部网应用程序(因此我使用Windows身份验证) 这是一个MVC5应用程序(带有引导和jQuery功能-no.aspx页面) 实体框架6(代码优先) SQL Server精简版 VS 2013快速版 服务器:Windows 2008 R2,运行IIS 7 已安装修补程序KB980368 IIS已在asp.net中注册(命令aspnet_regiis.exe-i run) 我在服务器上有一些管理
- 这是一个内部网应用程序(因此我使用Windows身份验证)
- 这是一个MVC5应用程序(带有引导和jQuery功能-no.aspx页面)
- 实体框架6(代码优先)
- SQL Server精简版
- VS 2013快速版
- 服务器:Windows 2008 R2,运行IIS 7
- 已安装修补程序KB980368
- IIS已在asp.net中注册(命令aspnet_regiis.exe-i run)
- 发布方式:文件系统
- 目标位置:在服务器上创建的文件夹
- 配置:发布
- 数据库:此发布方法不支持数据库发布
- bin(System.Web.MVC、System.Web.Razor等)
- 内容
- 字体
- 剧本
- 观点
- Global.asax
- packages.config
- web.config
<a href="/Home/Contact">Contact</a>
我相信我已经展示了关于我的问题的所有重要信息。如果我遗漏了什么,请告诉我
我投入了大量的时间和精力来学习如何使用EF、jQuery等构建MVC应用程序。我让它在我的开发机器上工作。我很沮丧,因为它不能在生产环境中工作
我真的希望在这里能得到一些有价值的帮助
致以最良好的祝愿
Paulo Ricardo Ferreira@Paulo Ricardo Ferreira首先检查应用程序池是否设置为v4.0(如果未设置),然后选择它。并尝试使用cmd重新注册您的4.0版本,如图所示 点击回车,它将开始安装,然后重新启动系统,然后在iis中单击路由,该路由类似于顶部的//administrator,然后进入isapi和CGI限制选项卡。允许所有路径,如下图所示。
您如何添加虚拟目录?你没有在网站文件夹中添加网站吗?嗨,@SHammelburg!我在服务器上创建了文件夹。将网站发布到该文件夹,然后在IIS中添加一个指向该文件夹的虚拟目录。谢谢您的时间。那么您将虚拟目录添加到了哪个网站?当您在IIS中时,您应该添加一个网站并将其链接到服务器上的文件夹。您好,@SHammelburg!我就是这么做的。谢谢你抽出时间。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation defaultLanguage="vb" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="DbControleDeAcesso" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=|DataDirectory|\ControleDeAcesso.sdf" />
<add name="DbOrcamento" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=|DataDirectory|\Orcamento.sdf" />
</connectionStrings>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<defaultDocument>
<files>
<remove value="default.aspx" />
<remove value="iisstart.htm" />
<remove value="index.html" />
<remove value="index.htm" />
<remove value="Default.asp" />
<remove value="Default.htm" />
</files>
</defaultDocument>
<!-- <handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers> -->
</system.webServer>
</configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace Orcamento.UI
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Orcamento", action = "Index", id = UrlParameter.Optional }
);
}
}
}