owin报错No assembly found containing an OwinStartupAttribute

The following errors occurred while attempting to load the app.

No assembly found containing an OwinStartupAttribute.
No assembly found containing a Startup or [AssemblyName].Startup class.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of “false” in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.

在这里插入图片描述
web.config中添加一行代码

 <add key="owin:AutomaticAppStartup" value="false"/>

在这里插入图片描述

参考

  • 10
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
OWIN(Open Web Interface for .NET)是一个开放的Web应用程序接口,可以让你在.NET应用程序中使用不同的Web服务器和Web框架。OWIN允许你将Web服务器和应用程序分离开来,这样你可以使用不同的Web服务器来运行你的应用程序,而无需修改应用程序的代码。 在Winform应用程序中调用OWIN,你需要先安装 Microsoft.Owin.Hosting NuGet 包,然后在代码中使用以下代码启动OWIN: ```csharp using Microsoft.Owin.Hosting; using System; namespace WinformApp { public partial class Form1 : Form { private IDisposable _webApp; public Form1() { InitializeComponent(); } private void btnStart_Click(object sender, EventArgs e) { string baseAddress = "http://localhost:9000/"; _webApp = WebApp.Start<Startup>(url: baseAddress); MessageBox.Show("OWIN web server started at " + baseAddress); } private void btnStop_Click(object sender, EventArgs e) { _webApp.Dispose(); MessageBox.Show("OWIN web server stopped"); } } } ``` 在上面的代码中,我们使用WebApp.Start方法来启动OWIN服务器。我们还提供了一个名为Startup的类,该类用于配置OWIN应用程序。在这个类中,你可以添加中间件和路由,以确保请求被正确地路由到你的应用程序中。 ```csharp using Microsoft.Owin; using Owin; [assembly: OwinStartup(typeof(WinformApp.Startup))] namespace WinformApp { public class Startup { public void Configuration(IAppBuilder app) { // Add middleware and configure routes here } } } ``` 在上面的代码中,我们使用OwinStartup属性告诉OWIN要使用Startup类来配置应用程序。在Configuration方法中,我们可以添加中间件和路由来处理请求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

假装我不帅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值