Activate MVC Web site on IIS 7 Windows Server 2008 R2 Enterprise SP2

▼魔方 西西 提交于 2020-06-26 13:46:28

问题


I have create a new ASP.NET Core 2.1 project empty on Visual Studio 2019

This is generated by a line in the Startup.cs file

public class Startup
{
    // This method gets called by the runtime. Use this method to add services to the container.
    // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {

    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        app.Run(async (context) =>
        {
            await context.Response.WriteAsync("Hello World!");
        });
    }
}

The application can serve static files HTML from the wwwroot folder.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <p>test</p>
</body>
</html>

The project working on localhost

I need published it to a folder on remote server with SO Windows Server 2008 R2 Enterprise SP2.

I had IIS 7 installed on server.

I installed .Net 4.5.2 and asp.net 2.1 core runtime and asp.net core 3.1 runtime on the server 2008 R2 SP2

I copied the folder contiaining my published Web site to \inetpub\wwwroot on the server.

With this post I configured MVC website in IIS.

https://www.codeproject.com/Articles/1168712/How-to-Quickly-Configure-your-MVC-Website-in-IIS

But on the server the return is

When click on wwwroot project folder

What do I do to give the Web site a URL and otherwise make it active as a Web site?

Maybe I have to install more on the server?

update

Installed on the server

it finally worked thanks to everyone for the support and help


回答1:


We should use DotNet build, DotNet publish command to publish our website rather than copy the project file to the website directory.
https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=netcore-cli
In Visual studio, we just need to use the below menu to publish website since VS is a strong, powerful IDE.

Select folder and type the physical path of the website.

At last, we need to install the corresponding Asp.Net hosting bundles(2.1 version instead of 3.1) in order to host Asp.net core web application in IIS.

Result.

Feel free to let me know if the problem still exists.




回答2:


You are probably missing https://dotnet.microsoft.com/permalink/dotnetcore-current-windows-runtime-bundle-installer

Read more at https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=visual-studio



来源:https://stackoverflow.com/questions/62154348/activate-mvc-web-site-on-iis-7-windows-server-2008-r2-enterprise-sp2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!