[英]Apply SignalR to ASP.NET Website
我正在尝试为我的网站(ASP.NET C#)创建聊天室。 一开始,我选择ASP.NET网站来开发我的网站,而不是ASP.NET Web应用程序 。
在我尝试应用SignalR之前,一切似乎都还不错。
我有必需的引用,并且.dll
也由NuGet在以下路径下载(例如)
D:\CL\CL\packages\Microsoft.Owin.2.1.0\lib\net45\Microsoft.Owin.dll
现在的问题是Startup.cs (如下所示)
using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(CL.Startup))]
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
// Any connection or hub wire up and configuration should go here
app.MapSignalR();
}
}
由于我的网站是作为ASP.NET网站创建的,因此它没有名称空间。 因此,CL.Startup部分会产生以下错误。
System.EntryPointNotFoundException: The following errors occurred while attempting to load the app.
- The OwinStartupAttribute.FriendlyName value '' does not match the given value 'CL.Startup' in Assembly 'App_Code.g9dw5cpb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
- The given type or method 'CL(1).Startup' was not found. Try specifying the Assembly.
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.
ASP.NET网站是否有其他方法可以应用SignalR? 或者是否有其他建议的解决方案来为我的网站实现聊天室?
谢谢。
我正在查看一些较早的信号器项目,我认为您缺少OwinStartupAttribute类和项目名称空间,请在首次创建该项目时将其称为项目名称空间,并将属性添加到程序集。
using Microsoft.Owin;
using Owin;
[assembly: OwinStartupAttribute(typeof(CL.Startup))]
namespace CL
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
此OwinStartupAttribute类
用于标记程序集中的哪个类应用于自动启动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.