prog1011
prog1011

Reputation: 3495

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. of some other project. That same .dll is also using in my another Web Application which is made in WebForms (.aspx) pages.

Now my question is: some function from that .dll are accepting Page.Application as a parameter. Which is working fine in .aspx page. BUT now I want to use same function in MVC application. But in MVC controller I am not able to access that 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

Thanks,

EDIT:- I am not asking about Application variable - I am asking about Page.Application which is object of HttpApplicationState . I want this HttpApplicationState in MVC Controller

Upvotes: 1

Views: 715

Answers (2)

Ajay2707
Ajay2707

Reputation: 5798

In mvc, there is no page lifecycle as in webform. Every thing from routing machanism.

While page.application, it is gets the HttpApplicationState object for the current Web request.

From MVC3 it support HttpApplicationState variable in mvc.

Check this answer :

HttpApplicationState not available in an MVC controller

Does asp.net MVC have Application variables?

Upvotes: 2

Mahdi Shahbazi
Mahdi Shahbazi

Reputation: 1073

you can use:

HttpContext.Application

and You have to add :

using System.Web;

Upvotes: 0

Related Questions