ASP.. NET Core在集成到IIS时无法找到view
本文关键字:view IIS Core 集成 ASP NET | 更新日期: 2023-09-27 18:01:27
我已经建立了一个ASP。. NET Core应用程序,并希望在我的Win2008服务器上推出此应用程序。如果我直接在kestrel中启动应用程序(双击包含main的exe),一切都很好。但是,如果我通过IIS启动应用程序,我会得到以下异常:
失败:Microsoft.AspNetCore.Server.Kestrel [13]连接id "0HKU0DCR0LPSS":应用程序抛出了一个未处理的异常。系统。InvalidOperationException:视图"Login"没有找到。搜寻的地点如下:/视图/账户/登录。cshtml/视图/共享/登录。cshtml在Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful (IEnumerable"1originalLocations)Microsoft.AspNetCore.Mvc.ViewResult.d__26.MoveNext ()
正是这个例外已经在这个问题中讨论过了。但是我将我的文件与建议的解决方案进行了比较,仍然得到了错误。
我还注意到,如果我通过IIS启动应用程序,那么最初放置在application.exe旁边的配置文件必须移动到wwwroot文件夹内。
这是我的网页内容。位于wwwroot文件夹内的配置:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="..'ERMSClient.exe" arguments="" stdoutLogEnabled="true" stdoutLogFile="..'logs'stdout" />
</system.webServer>
</configuration>
这是project。json
{
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
"Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNetCore.Server.WebListener": "0.1.0",
"Microsoft.AspNetCore.Http": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Microsoft.AspNetCore.Mvc.ApiExplorer": "1.0.0",
"Microsoft.AspNetCore.Mvc.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Session": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Newtonsoft.Json": "9.0.1",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"System.Web.Helpers.dll": "1.0.0",
"AutoMapper": "5.0.2",
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.0.0-preview2-final",
"Microsoft.Extensions.Configuration": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net461": {
"dependencies": {
"d3Communicator": {
"target": "project"
}
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "npm install", "bower install" ],
"postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
}
}
此外,我不得不提的是,我已经从ASP升级了这个项目。净RC1。因此,我可能有一个旧的条目或其他地方的东西。
我找到了非常非常简单的答案。不知怎么的,我假设我必须将IIS站点的物理路径指向ASP的wwwroot目录。. NET Core项目。这是不正确的,物理路径必须指向wwwroot上面的完整发布目录。