我有多租户ASP.NET MVC应用程序,它利用子域来确定当前租户。域是否有效是通过数据库表查找来确定的。
哪里是检查域是否在数据库中的函数的最佳位置?如果子域不在数据库中,则应重定向到Error
控制器中的Index
操作。
将检查放在Global.asax
文件中的Application_BeginRequest
方法中不起作用,因为会产生永不终止的重定向。
我有多租户ASP.NET MVC应用程序,它利用子域来确定当前租户。域是否有效是通过数据库表查找来确定的。
哪里是检查域是否在数据库中的函数的最佳位置?如果子域不在数据库中,则应重定向到Error
控制器中的Index
操作。
将检查放在Global.asax
文件中的Application_BeginRequest
方法中不起作用,因为会产生永不终止的重定向。
哪里是检查域是否在数据库中的函数的最佳位置?如果子域不在数据库中,则应重定向到“错误”控制器中的“索引”操作。
将检查放在Global.asax文件中的Application_BeginRequest方法中是不起作用的,因为会产生永无止境的重定向。
这是正确的位置,您只需要检查请求Url是否已经存在/Error。
您可能已经在这样做了,但我想补充一点,它似乎是非常静态的信息,您应该缓存这些信息,而不是针对每个请求访问数据库。
u可以子类化actionFilter属性并覆盖onactionExecuting方法。在这种方法中,u可以进行任何数据库检查并适当地重定向用户
public class CustomActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if(DatabaseLookup)
{
return;
}
filterContext.Result = new RedirectResult("http://servername/Error");
}
}
现在,您可以使用这个自定义actionfilter属性装饰您的操作方法
[CustomActionFilter]
public ActionResult mymethod()
{
//action method goes here
}
I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...
I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...
What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...
let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...
I started out this morning working with my ASP.NET MVC project like normal and everything worked. I added a new class and some functions and it still worked. Then, all of a sudden, while I was ...
I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...
So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...
i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...