Tag: asp.net mvc

具有多个参数的“绑定”的Ninject语法

我如何在Ninject语法中使用多个参数,如下所示? Bind() .To() .WithConstructorArgument(“connectionString”, ConfigurationManager.ConnectionStrings[“MyDb”].ConnectionString ); 如果需要传递多个参数怎么办?

在AppPool循环后重新连接时,MVC5挂起在MapSignalR上

我在Startup.SignalR.cs中有以下代码: using Microsoft.AspNet.SignalR; using Owin; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Admin { public partial class Startup { public void ConfigureSignalR(IAppBuilder app) { var Config = new HubConfiguration() { EnableDetailedErrors = false, Resolver = new DefaultDependencyResolver() }; #if DEBUG Config.EnableDetailedErrors = true; #endif // Any connection or hub wire up […]

发现多个类型与名为“Home”的控制器相匹配 – 在两个不同的区域中

我的项目有两个方面。 现在,当我运行程序时,我收到此错误: Multiple types were found that match the controller named ‘Home’. This can happen if the route that services this request (‘{controller}/{action}/{id}’) does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the ‘MapRoute’ method that takes a […]

跨多个子域的URL路由

我发现自己处境艰难。 我们正在开发一个ASP.NET MVC 2应用程序,它由多个部分组成。 设计目标是让这些部分跨越多个子域。 每个子域都有自己的控制器。 挑战在于我们的托管服务提供商的控制面板允许对子域进行两种forms的重定向,而且这两种forms都不符合要求。 选择是: 重定向到URL。 选择是否重定向到相对于请求URL的确切目的地或目的地。 重定向到我的主机空间中的特定文件夹。 我将尝试说明预期的行为。 假设默认路由是{controller}/{action}/{id} ,我希望URL http://subdomain.welcome.com/a/b由MVC应用程序处理,如http://welcome.com/subdomain/a/b 。 URL重定向可以解决此问题,除了用户在浏览器中看到URL更改的事实。 我们不希望客户端看到重定向发生。 重定向到我们的MVC应用程序根文件夹根本不起作用。 该应用程序不会接收请求,IIS会传回4xx错误。 编辑: 为了找到答案,我会简化一下。 “重定向到URL”不能执行我想要的操作,因此会重定向到文件夹。 如果我将子域重定向到我的MVC应用程序的根文件夹并且IIS不会接收请求,这是IIS或我的提供商的限制吗?

asp.net MVC 3中的ViewData和PageData有什么区别?

嗯,我看到这2个属性,但我不明白它们之间的区别? 我似乎无法在任何地方找到任何有关PageData礼仪的帮助。 所以身体有帮助吗? @ { Viewdata[“something”] = 1; PageData[“something”] = 2; } 谢谢

应用CQRS – 是否需要对薄读取层进行unit testing?

鉴于实现CQRS的一些建议提倡相当接近金属的查询实现,例如直接针对数据库(或者可能是基于LINQ的ORM)的ADO.NET查询,尝试unit testing是错误的他们? 我想知道它是否真的有必要吗? 我对此事的看法: 提供可模拟的“薄读取层”的额外架构复杂性似乎与将建筑仪式保持在最低限度的建议的本质相反。 有效覆盖用户可能构成的每个查询角度的unit testing数量是可怕的。 具体来说,我正在ASP.NET MVC应用程序中尝试CQRS,并且想知道是否打扰unit testing我的控制器操作方法,或者只是测试域模型。 提前谢谢了。

在ASP.NET MVC 4 C#Code First中指定ON DELETE NO ACTION

如何在模型设计中指定ON DELETE NO ACTION外键约束? 目前,我有: public class Status { [Required] public int StatusId { get; set; } [Required] [DisplayName(“Status”)] public string Name { get; set; } } public class Restuarant { public int RestaurantId { get; set; } [Required] public string Name { get; set; } [Required] [EmailAddress] public string Email { get; set; } […]

MVC C#TempData

有人可以在MVC中解释TempData的用途。 我知道它的行为与ViewBag相似,但除此之外还有什么作用。

如何在Web App Service中使用“Azure文件存储”?

我一直在努力寻找一些资源来帮助解释我们如何使用文件存储与Web App服务。 有一些方法可以将它与旧的Web角色一起使用,请点击此处http://fabriccontroller.net/blog/posts/using-the-azure-file-service-in-your-cloud-services-web-roles-and-工人角色/ 但是,“Azure Web服务”中没有OnStart()方法。

如何在MVC中使用会话变量

我在“Global.asax”文件中声明了Session变量, protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); int temp=4; HttpContext.Current.Session.Add(“_SessionCompany”,temp); } 并希望将此会话变量用于我的控制器的操作, public ActionResult Index() { var test = this.Session[“_SessionCompany”]; return View(); } 但是我在访问会话变量时遇到exception。 请帮我解决这个问题,如何将会话变量访问到我的控制器的Action中。 我在Global.asax中的Application_Start中获得了一个exception,例如”Object Reference not set to an Insatance of an object” HttpContext.Current.Session.Add(“_SessionCompany”,temp);