[英]Hosting Asp.Net Core 2 on IIS
My application works good when started in Release/Debug mode via Visual Studio in both ApplicationName and IISExpress. 在ApplicationName和IISExpress中通过Visual Studio在Release / Debug模式下启动时,我的应用程序运行良好。
But once deployed to IIS and started, I cannot access home page (home controller) and also have Navigation bar issues and JQuery issues. 但是一旦部署到IIS并启动,我就无法访问主页(家庭控制器),也有导航栏问题和JQuery问题。 I have published the app in both Debug/Release mode to no avail. 我在调试/发布模式下发布了应用程序无济于事。
My question mainly is how can I fix this? 我的问题主要是如何解决这个问题? The app should run the same way it runs locally on iisexpress right? 应用程序的运行方式与iisexpress本地运行的方式相同吗? Even if a file was missing (as in debug/release env), Home controller should be access as is right? 即使文件丢失(如在debug / release env中),Home控制器应该是正确的访问权限?
Will greatly appreciate any help and waiting to post more information and logs based on comments. 非常感谢任何帮助,并等待根据评论发布更多信息和日志。
Edit 1 (to include Startup.cs): 编辑1(包括Startup.cs):
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using MTAClassLib.Configuration;
using System.IO;
namespace MTALib
{
public class Program
{
public static void Main(string[] args)
{
var host = BuildWebHost(args);
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
var RoleManager = services.GetRequiredService<RoleManager<IdentityRole>>();
UserRoleSeed.Seed(RoleManager).Wait();
}
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.Build();
}
}
I had same issue with having ASP.Net Core 2 run on IIS. 我在IIS上运行ASP.Net Core 2时遇到了同样的问题。 I had to 我不得不
Ensure that your project.cs BuildWebHost method looks as follows 确保project.cs BuildWebHost方法如下所示
public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build();}
I didn't have to change application pool to .NET CLR version to "No Managed Code". 我没有必要将应用程序池更改为.NET CLR版本为“No Managed Code”。 It remained as ".Net CLR Version v4.0.30319" 它仍然是“.Net CLR Version v4.0.30319”
This solved mine. 这解决了我的问题
Hosting of ASP.NET Core 2.0 is a little different from hosting in ASP.NET. ASP.NET Core 2.0的托管与ASP.NET托管有点不同。
You need to Install the .NET Core Hosting Bundle 您需要安装.NET Core Hosting Bundle
Also, make sure your Application Pool >> .NET CLR version should be No Managed Code 此外,请确保您的应用程序池 >> .NET CLR版本应为无管理代码
For more details refer to Host ASP.NET Core on Windows with IIS 有关更多详细信息,请参阅带有IIS的Windows上的Host ASP.NET Core
安装“dotnet-hosting-2.1.2-win.exe”并重置IIS已经解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.