如何在IIS上托管我的ASP.NET核心站点(在开发环境中,而无需部署/发布) [英] How to host my ASP.NET core site on IIS (in development environment, without deploy / publish)

查看:80
本文介绍了如何在IIS上托管我的ASP.NET核心站点(在开发环境中,而无需部署/发布)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经在开发环境中将IIS的ASP.NET站点(不是核心站点)本地托管在IIS上.
这样做有助于避免使用IIS Express(每次启动和停止IIS Express都非常不舒服).
这样,我要做的就是重建并刷新该网站.
我的目标是以相同的方式使用ASP.NET核心.
我读了这篇文章: https://docs.microsoft. com/en-us/aspnet/core/publishing/iis?tabs = aspnetcore2x ,但运行不正常.
我正在寻找的是在每次C#代码更改(需要构建)后不进行部署/发布的情况下执行此操作.
我使用ASP.NET Core 2& IIS 10

I used to host my ASP.NET sites (not core) on IIS locally, in my development environment.
Doing it helped me avoiding from using IIS Express (It's very uncomfortable to start & stop IIS express every time).
In this way all I had to do is to rebuild and refresh the site.
My goal is to work with ASP.NET core in the same way.
I read this: https://docs.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x and it didn't go well.
What I'm looking for is to do it without deploy / publish after every C# code change (that requires building).
I use ASP.NET core 2 & IIS 10

推荐答案

如果需要调试应用程序,则可以将ASP.NET Core应用程序配置为默认的IIS启动程序.

If you need to debug an application, you can configure the ASP.NET Core application as the default IIS startup.

参考: https://docs.microsoft.com/aspnet/core/host-and-deploy/iis/development-time-iis-support#configure-the-project

创建一个新的启动配置文件以添加开发时的IIS支持.在Visual Studio的解决方案资源管理器中,右键单击该项目,然后选择属性.选择调试标签.从启动下拉列表中选择 IIS .确认已使用正确的URL启用了启动浏览器功能.

Create a new launch profile to add development-time IIS support. In Visual Studio's Solution Explorer, right-click the project and select Properties. Select the Debug tab. Select IIS from the Launch dropdown. Confirm that the Launch browser feature is enabled with the correct URL.

或者,将启动配置文件手动添加到应用程序中的 launchSettings.json 文件中:

Alternatively, manually add a launch profile to the launchSettings.json file in the app:

{
"iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
        "applicationUrl": "http://localhost/WebApplication2",
        "sslPort": 0
    }
},
"profiles": {
    "IIS": {
        "commandName": "IIS",
        "launchBrowser": "true",
        "launchUrl": "http://localhost/WebApplication2",
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        }
    }
}

这篇关于如何在IIS上托管我的ASP.NET核心站点(在开发环境中,而无需部署/发布)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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