![](/img/trans.png)
[英]How do I set up a site in IIS7 on Windows 2008 Server Web SP2 via a console application?
[英]Activate MVC Web site on IIS 7 Windows Server 2008 R2 Enterprise SP2
我在 Visual Studio 2019 上創建了一個空的新 ASP.NET Core 2.1 項目
這是由 Startup.cs 文件中的一行生成的
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 文件夾提供 static 文件 HTML。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<p>test</p>
</body>
</html>
在本地主機上工作的項目
我需要使用 SO Windows Server 2008 R2 Enterprise SP2 將其發布到遠程服務器上的文件夾。
我在服務器上安裝了 IIS 7。
我在服務器2008 R2 SP2上安裝了.Net 4.5.2和asp.net 2.1 core runtime和asp.net core 3.1 runtime
我將包含我已發布的 Web 站點的文件夾復制到服務器上的\inetpub\wwwroot
。
通過這篇文章,我在 IIS 中配置了 MVC 網站。
https://www.codeproject.com/Articles/1168712/How-to-Quickly-Configure-your-MVC-Website-in-IIS
但在服務器上,返回是
單擊 wwwroot 項目文件夾時
我該怎么做才能為 Web 站點提供 URL 並使其作為 Web 站點處於活動狀態?
也許我必須在服務器上安裝更多?
更新
安裝在服務器上
終於成功了,感謝大家的支持和幫助
我們應該使用DotNet build
, DotNet publish
命令來發布我們的網站,而不是將項目文件復制到網站目錄。
https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=netcore-cli
在Visual studio
中,我們只需要使用下面的菜單來發布網站,因為 VS 是一個強大、強大的 IDE。
Select 文件夾並輸入網站的物理路徑。
最后,我們需要安裝相應的 Asp.Net 托管包(2.1 版本而不是 3.1),以便在 IIS 中托管 Asp.net 核心 web 應用程序。
結果。
如果問題仍然存在,請隨時告訴我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.