【问题标题】:How to make the server use the startup.cs instead of Global.asax.cs如何让服务器使用 startup.cs 而不是 Global.asax.cs
【发布时间】:2015-04-14 15:30:24
【问题描述】:

我正在尝试在网络上发布一个应用程序,但服务器搜索 Global.asax.cs,我删除了该文件并添加了 startup.cs。

如何让服务器搜索 startup.cs 而不是 Global.asax.cs,或者解决此问题的最佳方法是什么?

【问题讨论】:

标签: c# asp.net-mvc-5 server


【解决方案1】:

您必须从 Nuget 添加 Owin 包并使用如下所示的启动类:

using Owin;
using Microsoft.Owin;
[assembly: OwinStartup(typeof(YOURNAMESPACE.Startup))]
namespace YOURNAMESPACE
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            //DO your stuff
        }
    }
}

希望对你有帮助

【讨论】:

  • 我有这个文件。但是当我将项目推送到测试服务器时,它会搜索 global.asax.cs 但我删除了,因为我添加了 startup.cs 文件。如何配置服务器以搜索 startup.cs 而不是 global.asax.cs
  • 我认为没有理由删除 global.asax.cs。如果你有一个像这样的启动类,它会使用这个。
  • 嗯,所以我应该添加 global.asax.cs 和 startup.cs。好的,谢谢你..我会试试看它是否有效:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-26
相关资源
最近更新 更多