在MVC中检查连接字符串存在的最佳方法的Application_Start [英] Best way to check for connection string existance in MVC || Application_Start

查看:43
本文介绍了在MVC中检查连接字符串存在的最佳方法的Application_Start的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,



我想执行一项任务,测试Application_Start上web.config中连接字符串和一些app键的存在,并重定向到某些特定的控制器的视图或动作......但我发现应用程序使用IIS集成模式时没有请求/响应上下文的限制。





那么任何机构都可以指出这方面的最佳做法吗?

Hey All,

I want to perform a task of testing the existance of connection string and some app keys in web.config on Application_Start and redirect to some specific view or Action of Controller... But i came to know that there are limitations of No Request/Response context while application is using the IIS integrated mode.


So can any body point out the best practice in this regard?

推荐答案

这里有一些问题...

在较新的(我认为是7个)IIS中你可以启动应用程序(池)而无需任何用户交互(在旧版本中第一个请求启动了应用程序),因此在另一端有一个没有人接收的情况视图/动作的输出...

如果我理解正确,如果配置中缺少参数,则需要将用户重定向到特定页面...只能根据特定请求进行操作(就像在登录页面的情况一样显示在一个简单的请求中间,并在登录完成后重定向到同一个请求)...

所以Application_Start不是一个很好的开始,但也许Request_Begin ......但是我也会考虑谁,何时可以设置这些配置参数...
You have some problem here...
In newer (since 7 I think) IIS you can start application (pool) without any user interaction (in older version the first request started the application), so there is a situation with no-one on the other end to receive a view/action's output...
If I understood correctly, you want to redirect user to a specific page if there are missing parameters in the configuration...It can be done only upon a specific request (like in case of login page, that shows in the middle of a simple request and redirects to the same request after login completed)...
So Application_Start is not a good point to start, but maybe Request_Begin...However I would consider also who, and when can set those configuration parameters...


这篇关于在MVC中检查连接字符串存在的最佳方法的Application_Start的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆