English 中文(简体)
如何处理违约 工厂创建主计长
原标题:How to gracefully handle DefaultControlFactory s CreateController

我的网页上有一些链接,尚未建立控制员。 我有我的习惯控制工厂,如:

 public class MyControllerFactory : DefaultControllerFactory
    {

        public override IController CreateController(RequestContext requestContext, string controllerName)
        {
            try
            {
                IController controller = base.CreateController(requestContext, controllerName);
                HttpContext.Current.Items["Controller"] = controller;
                return controller;
            }
            catch { return null; }
        }

    }

只要能够找到控制者,就可处以罚款。 然而,如果我从我的手法中找回,我就扔下了黄色的死亡屏幕。 我怎么能轻松地处理这一问题? 我想向几页以及404个冰盖格式的信息转播,或可能显示一些信息,如“进步”。

最佳回答

你们是否试图增加这一点?

[HandleError(ExceptionType = typeof(NullReferenceException), Order = 1, View = "NotFound")]

各位将不得不对共同的看法增加一点点。 说明贵制工厂的情况。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签