在IIS 7 Windows Server 2008 R2 Enterprise SP2上激活MVC网站 [英] Activate MVC Web site on IIS 7 Windows Server 2008 R2 Enterprise SP2

查看:89
本文介绍了在IIS 7 Windows Server 2008 R2 Enterprise SP2上激活MVC网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Visual Studio 2019上创建了一个空的新ASP.NET Core 2.1项目

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

这是由Startup.cs文件中的一行生成的

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!");
        });
    }
}

该应用程序可以从wwwroot文件夹提供HTML静态文件.

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>

在localhost上运行的项目

The project working on localhost

我需要将其发布到具有SO Windows Server 2008 R2 Enterprise SP2的远程服务器上的文件夹中.

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

我在服务器上安装了IIS 7.

I had IIS 7 installed on server.

我在服务器2008 R2 SP2上安装了.Net 4.5.2和asp.net 2.1核心运行时以及asp.net核心3.1运行时

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

我将包含已发布网站的文件夹复制到服务器上的\inetpub\wwwroot.

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

通过这篇文章,我在IIS中配置了MVC网站.

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

当单击wwwroot项目文件夹时

When click on wwwroot project folder

我该怎么做才能为网站提供URL,否则可以使它作为网站活跃?

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?

更新

已安装在服务器上

它终于奏效了,感谢大家的支持和帮助

it finally worked thanks to everyone for the support and help

推荐答案

我们应该使用DotNet buildDotNet publish命令来发布我们的网站,而不是将项目文件复制到网站目录中.
https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=netcore-cli
Visual studio中,由于VS是一个强大的功能强大的IDE,我们只需要使用下面的菜单来发布网站.

选择文件夹,然后键入网站的物理路径.

最后,我们需要安装相应的Asp.Net托管捆绑包(2.1版本而不是3.1版本),以便在IIS中托管Asp.net核心Web应用程序.

结果.

随时让我知道问题是否仍然存在.

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.

这篇关于在IIS 7 Windows Server 2008 R2 Enterprise SP2上激活MVC网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆