我已经知道在这里问我可以在一个普通的旧Windows服务中使用SignalR.我想在Windows服务之间作为SignalR客户端和ASP.NET MVC SignalR服务器进行通信.它说,我使用了这个集线器指南
指定URL的服务器代码
app.MapSignalR("/signalr", new HubConfiguration());
Run Code Online (Sandbox Code Playgroud)
如果我这样做,消息会在哪里发生?进行新的HubConfiguration时,什么是集线器?
它说我可以联系
NET client code that specifies the URL
var hubConnection = new HubConnection("http://contoso.com/signalr", useDefaultUrl: false);
Run Code Online (Sandbox Code Playgroud)
我会在我的Windows Server中使用它,但如果我将文本发送到服务器上的http://myserver.com/signalr,我该如何获取它?什么集线器?
另外最好把它放在Windows服务中?一个例子会很棒!
我正在使用新的ASP.NET Identity 2.0系统.我知道我可以检查用户是否处于这样的角色:
bool isAdmin = UserManager.IsInRole(User.Identity.GetUserId(),
"Customer Account Admin");
Run Code Online (Sandbox Code Playgroud)
我想这个代码可以在运行某些代码之前编写以检查,但是[Authorize]属性呢.我曾经说过:
[Authorize(Role="Customer Account Admin")]
Run Code Online (Sandbox Code Playgroud)
这不再起作用了,因为我不再使用旧的成员资格或角色管理.我怎么把两者放在一起?或者,我如何防范应用程序的某些部分无法供正确角色的成员使用?
编辑1:我不相信它有效.我在管理页面上放置了以下Authorize属性,我可以将代码作为"客户帐户用户"执行
[Authorize(Roles = "Customer Service Admin, Savitas Admin")]
public partial class _default : System.Web.UI.Page
Run Code Online (Sandbox Code Playgroud)
此外,我想阻止该页面被未经授权的用户看到.我们有阻止菜单的代码,但我仍然可以输入管理页面的URL,未经授权的用户可以看到它
if (HttpContext.Current.User.IsInRole("Customer Account Admin"))
//
{
}
else
{
mi = radmenu1.Items.FindItemByText("Admin");
radmenu1.Items.Remove(mi);
}
Run Code Online (Sandbox Code Playgroud)
EDIT2:我们在ASpNetRoles表中手动创建了角色,并将用户映射到ASPNetUsersToRoles表中的角色.用户与"客户服务管理员"等角色之间存在映射.我们将用户添加到具有以下内容的角色,但我认为它不起作用:
if (manager.AddToRole(manager.FindByName(UserName.Text).Id, "Customer Account Admin").Succeeded)
{
c.logActivity("Register.aspx.cs", "REG_USER_ROLE", "Setting user to Admin role succeeded");
}
Run Code Online (Sandbox Code Playgroud)
当普通用户登录时,他们不会通过在地址栏中输入管理员页面获得管理员菜单:
http://localhost:53620/Admin/default
Run Code Online (Sandbox Code Playgroud)
我怎么阻止它?
编辑3:我试图按照你的示例Eric阻止所有用户访问管理员页面,但我再次以客户用户身份登录,仍然在地址栏中输入上述内容并进入页面.这有什么问题:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on …Run Code Online (Sandbox Code Playgroud) 我正在尝试基于此演练创建一个简单的Windows服务.当我尝试执行命令时:
C:\worl\Project Alpha\Code\AlphaBackendService\AlphaBackendService\bin\Debug>ins
tallutil.exe AlphaBackendService.exe
Run Code Online (Sandbox Code Playgroud)
它会显示一个对话框,其中包含用户名,密码,确认密码.我没有输入任何内容,安装失败.它想要什么帐户?为什么我不能只使用我输入的任何内容?这是因为EventLog需要权限:
public partial class AlphaBackendService : ServiceBase
{
public AlphaBackendService()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("AlphaSource"))
{
System.Diagnostics.EventLog.CreateEventSource("AlphaSource", "AlphaLog");
}
eventLog1.Source = "AlphaSource";
eventLog1.Log = "AlphaLog";
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
}
protected override void OnStop()
{
eventLog1.WriteEntry("In OnStop");
}
}
Run Code Online (Sandbox Code Playgroud)

我有一些VB.NET代码,我正在转换为C#.它使用XmlDictionaryWriter和XmlDictionaryReaderQuotas,根据MSDN,它们都在System.Xml和程序集中System.Runtime.Serialization.我添加了System.Runtime.Serialization作为参考.它一直说不能找到它们.这是VB.NET代码:
Dim xmlreader As System.Xml.XmlDictionaryReader
Dim quotas As New System.Xml.XmlDictionaryReaderQuotas
xmlreader = JsonReaderWriterFactory.CreateJsonReader(result, quotas)
Run Code Online (Sandbox Code Playgroud)
这是在VS2013/.NET Framework 4中
我有一个 Web ASP.NET 站点,它可以与 WCF 服务一起正常工作。现在,我有一个 Telerik Reports 类库,它也需要调用这些相同的 Web 服务。我不断收到错误无法加载类型“System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider”。当我尝试向 Web 服务添加服务引用时。我已经搜索了该主题并完成了人们指出的一切。在实现 Web 服务和站点的项目中,配置具有:
compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="Telerik.ReportViewer.WebForms, Version=8.0.14.225, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" />
<add assembly="Telerik.Reporting, Version=8.0.14.225, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" />
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
</buildProviders>
Run Code Online (Sandbox Code Playgroud)
在类库配置中:
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add …Run Code Online (Sandbox Code Playgroud) 我有一个ASP.NET(以前的MVC)服务器和Windows服务客户端之间的SignalR工作,客户端可以调用Server Hub上的方法,然后显示给浏览器.Hub代码是:
public class AlphaHub : Hub
{
public void Hello(string message)
{
// We got the string from the Windows Service
// using SignalR. Now need to send to the clients
Clients.All.addNewMessageToPage(message);
// Call Windows Service
string message1 = System.Environment.MachineName;
Clients.All.Notify(message1);
}
public void CallForReport(string reportName)
{
Clients.All.CallForReport(reportName);
}
Run Code Online (Sandbox Code Playgroud)
在客户端(Windows服务)上,我一直在调用Hub上的方法:
var hubConnection = new HubConnection("http://localhost/AlphaFrontEndService/signalr",
useDefaultUrl: false);
IHubProxy alphaProxy = hubConnection.CreateHubProxy("AlphaHub");
await hubConnection.Start();
string cid = hubConnection.ConnectionId.ToString();
eventLog1.WriteEntry("ConnectionID: " + cid);
// Invoke method on hub
await alphaProxy.Invoke("Hello", "Message …Run Code Online (Sandbox Code Playgroud) 我正在使用EF,我有以下代码,我试图从一个名为interface5toSSHIP的视图中获取行.SQL Explorer显示数据库视图现在有一行.以下查询似乎没有返回它.我究竟做错了什么?
IEnumerable<interface5toSSHIP> i5;
using (RREM_GilbaneEntities3 entities3 = new RREM_GilbaneEntities3())
{
i5 = from i in entities3.interface5toSSHIP
select i;
}
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试DataBind时,我得到标题错误:
grdvwInterface5ReadyToSend.DataSource = i5;
grdvwInterface5ReadyToSend.AllowPaging = true;
grdvwInterface5ReadyToSend.AllowSorting = true;
grdvwInterface5ReadyToSend.DataBind();
Run Code Online (Sandbox Code Playgroud)
问题是我找不到怎么做Load.我查了一个像这样的例子:
IntranetModelContainer db = new IntranetModelContainer();
db.Entities.OfType<Employee>().Load();
return db.Entities.Local.OfType<Employee>();
Run Code Online (Sandbox Code Playgroud)
我添加了对System.Data.Entity的引用,我找不到我的entities3或LOAD方法的.Entities.我该怎么做呢?
我在 Windows 服务中有一个 SignalR 客户端,它成功调用 MVC 应用程序中的服务器方法。首先是服务器代码:
public class AlphaHub : Hub
{
public void Hello(string message)
{
// We got the string from the Windows Service
// using SignalR. Now need to send to the clients
Clients.All.addNewMessageToPage(message);
// Send message to Windows Service
}
Run Code Online (Sandbox Code Playgroud)
和
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
app.MapSignalR("/signalr", new HubConfiguration());
}
}
Run Code Online (Sandbox Code Playgroud)
Windows 服务客户端是:
protected override async void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
try
{
var hubConnection = new HubConnection("http://localhost.com/signalr", …Run Code Online (Sandbox Code Playgroud) 有人告诉我不要使用RSA 来加密简单的文本,而是使用 AES。我找到了一段简单的代码来实现 AES:
public static class Crypto
{
#region Settings
private static int _iterations = 2;
private static int _keySize = 256;
private static string _hash = "SHA1";
private static string _salt = "aselrias38490a32"; // Random
private static string _vector = "8947az34awl34kjq"; // Random
#endregion
public static string Encrypt(string value, string password)
{
return Encrypt<AesManaged>(value, password);
}
public static string Encrypt<T>(string value, string password)
where T : SymmetricAlgorithm, new()
{
byte[] vectorBytes = Encoding.ASCII.GetBytes(_vector);
byte[] saltBytes = …Run Code Online (Sandbox Code Playgroud) 我们有一个场景,我们有两个SQL Server数据库,一个用于测试,一个用于部署.当我进入项目时,他们一直在使用类型化数据集并传递连接字符串以确定哪个数据库.两者都只有一个类型化的数据集.
现在,我正在尝试使用Entity Framework执行此操作.虽然我可以在同一个类库中有两个EDMX模型,但是catch都是数据库具有相同的表,因此生成具有相同名称的相同C#类并且存在冲突.
无论如何要处理这种情况?
我一直在使用Fiddler为一些调用其他ASMX服务的ASMX服务捕获流量.在这种情况下,我有一个简单的WCF服务调用那些ASMX服务.它不会捕获任何流量.唯一的缺点是它使用IIS而不是IISExpress (http://localhost/Interface12Service/Interface12Service.svc).如何捕获WCF流量?
c# ×8
asp.net ×4
signalr ×3
.net ×2
asp.net-mvc ×2
wcf ×2
aes ×1
cryptography ×1
encryption ×1
fiddler ×1
sql-server ×1
vb.net ×1
xml ×1