简体   繁体   English

什么是MVC Controller中的Page.Application(在.aspx.cs页中)等效

[英]What is the equivalent of Page.Application (in .aspx.cs page) In MVC Controller

I am working on MVC web application, and I am using .Dlls . 我正在开发MVC Web应用程序,并且正在使用.Dlls of some other project. 其他一些项目 That same .dll is also using in my another Web Application which is made in WebForms (.aspx) pages. 我的另一个Web应用程序中也使用了相同的.dll,该Web应用程序是在WebForms(.aspx)页面中创建的。

Now my question is: some function from that .dll are accepting Page.Application as a parameter. 现在我的问题是: .dll中的某些函数正在接受Page.Application作为参数。 Which is working fine in .aspx page. 在.aspx页中哪个工作正常。 BUT now I want to use same function in MVC application. 但是现在我想在MVC应用程序中使用相同的功能。 But in MVC controller I am not able to access that Page.Application 但是在MVC controller我无法访问该Page.Application

So Please someone can help me That How can I access Page.Application in MVC Controller and Is there any equivalent of Page.Application in MVC Controller 因此,请有人可以帮助我,我该如何访问MVC Controller中的Page.Application ,以及MVC Controller中是否有等效的Page.Application

Thanks, 谢谢,

EDIT:- I am not asking about Application variable - I am asking about Page.Application which is object of HttpApplicationState . 编辑:-我不是问Application variable -我问的是Page.Application这是HttpApplicationState对象。 I want this HttpApplicationState in MVC Controller 我想要MVC Controller中的HttpApplicationState

In mvc, there is no page lifecycle as in webform. 在mvc中,没有网页形式的页面生命周期。 Every thing from routing machanism. 路由机制的一切。

While page.application, it is gets the HttpApplicationState object for the current Web request. 在page.application时,它获取当前Web请求的HttpApplicationState对象。

From MVC3 it support HttpApplicationState variable in mvc. 从MVC3开始,它在mvc中支持HttpApplicationState变量。

Check this answer : 检查此答案:

HttpApplicationState not available in an MVC controller HttpApplicationState在MVC控制器中不可用

Does asp.net MVC have Application variables? asp.net MVC是否具有应用程序变量?

you can use: 您可以使用:

HttpContext.Application

and You have to add : 并且您必须添加:

using System.Web;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM