Access The HttpServerUtility Instance In MVC Controller?

Nov 17, 2010

How can I access the HttpServerUtility instance in ASP.NET MVC controller?

View 1 Replies


Similar Messages:

C# - Manually Instantiate Controller Instance From Arbitrary URL?

Jan 14, 2010

My skills are failing me, and I know I've seen the code around for this but I can't find it. What's the quickest way to take any arbitrary URL, run it through your asp.net mvc routing system, and come out with a reference to a controller instance on the other end?For example, code execution is inside some arbitrary controller method. I want to do something like this:

...
string myURL = "[URL]";
RouteData fakeRouteData = new RouteData(Route???, IRouteHandler???)
RequestContext ctxt = new RequestContext(this.ControllerContext.HttpContext,
fakeRouteData);
ControllerFactory factory = ControllerBuilder.Current.GetControllerFactory();
Controller result = factory.CreateController(ctxt, controllername???)

I'm trying to get an instance of a controller just like the routing system does, regardless of where the code is executing. I'm unclear as to how to fit the pieces together at this point.

View 3 Replies

C# - .NET HttpServerUtility.Transfer Break The Control Flow?

Sep 30, 2010

By "how does" I mean "by what mechanism" not "to what effect". Control doesn't return to the calling method after you call Server.Transfer("...");. At the language runtime level, how does this happen? Does it throw an exception or trigger something that aborts the thread? I'm just curious. What are other examples of this pattern (calling a method to terminate execution)?

View 1 Replies

MVC :: Access Instance Of Layout Page?

Oct 12, 2010

There seem to be a few issues in the way Razor views are designed and the code generated

1. Descendants of WebViewPage are forced to override Execute() (since it is abstract) but that method is never called. Why?
2. The virtual method ConfigurePage is never called in descendants that override this method.
3. CreatePageFromVirtualPath is no longer virtual. This was the one method that gave us access to the Layout Page (Master Page) instance. Now we no longer have this access. Why was this done?

How can one get access to the instance of a Layout page?

View 4 Replies

MVC :: Access The Session On The Controller?

Jan 30, 2010

I am trying to get into grips with AJAX/JQuery and MVC. i need to access the session on the controller. This doesnt seem to be initialised at the constructor level but there needs to be a way I can store items in the session in the constructor depending on the parameter values (an extra constructor is written here) I am also doing unit testing here, which has been provided by 3rd party and they are using this extra constructor.

So the idea here is that when the page is loaded, JQuery will request a collection of items (which will be stored in session) and also be able to post to the page so items are added into the collection too. So, what is the best way here to get access to the session in the constructor of a controller?

View 4 Replies

MVC :: Use The Same View To Access The Different Controller?

Jan 18, 2011

I am new to MVC. Now I have an application needs to be built using MVC. I want to show all the information in one view(or form), but the data are coming from different controllers. how the system knows the data in textbox1 goes to controller1 and the data from database in controller2 returns to textbox2 in the same view(or form)?

View 7 Replies

Access Instance Of A Radiobutton From Radiobuttonlist Through Javascript?

Feb 8, 2010

If we are using ASP.NET Radiobuttonlist in our page it becomes a little difficult to find the instance of it through Javascript because it is rendered in a different way in the browser ( the code is reproduced below )

[Code]....

View 2 Replies

C# - Using Grasp Controller With MVC Controller - How To Make An Object Always Visible For A Controller

Dec 28, 2010

UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, that follows the UP(Unified Process). It uses a Grasp Controller pattern to interact with domain classes by some methods like NewSale(), AddNewItemToSale() and CloseSale. In windows form, I can instantiate a object of this class in the UI and then use its methods to perform the actions. This works well in Client apps, but when I use asp.net mvc, I cannot find a way to instantiate an object (one for each user) that was always visible for a Controller (MVC). I cannot insert as an attribute inside Controller because it always create a new one.

View 1 Replies

MVC :: Access A Control In The Page Controller?

Mar 6, 2011

My question is if i put a dropdownlist on my webpage:

[Code]....

How do i acces this from my controller. If for example i want to make it visible or not?

View 2 Replies

Access Current Instance Of Page From A Static Class

Mar 22, 2010

Basic question - is it possible to access the current Page from a static class in ASP.NET?

I am thinking no, as google turns up no results.

View 3 Replies

MVC :: Can Access Masterpage Dropdown Value In Controller Action

Jan 17, 2011

I have a masterpage on which i displays groups that user can access now i want to gets its selected value in other controllers for saving with the records. I want to know if it is possible in asp.net mvc 2 and if not then what is the way around for it

View 1 Replies

Web Forms :: Access Class Instance Declared On Master From Content Page?

Apr 8, 2010

Can I access a class instance declared on the master page from a content page?

View 4 Replies

C# - What Are The Pros/cons Of Choosing Between Static And Instance Data Access Classes In A Web App

Jan 20, 2010

I've read several other questions on this topic (here, here, and here), but have yet to see a great answer. I've developed my fair share of data access layers before and personally prefer to use instance classes instead of static classes. However, it is more of a personal preference (I like to test my business objects, and this approach makes mocking out the DAL easier). I have used static classes to access the database before, but I've always felt a little insecure in the appropriateness of such a design (especially in an ASP.NET environment).

Can anyone provide some good pros/cons with regards to these two approaches to developing data access classes with ADO.NET providers (no ORM), in an ASP.NET application in particular. Feel free to chime in if you have some more general static vs. instance class tips as well.

In particular, the issues I'm concerned about are:

Threading & concurrency
Scalability
Performance
Any other unknowns

View 4 Replies

Forms Data Controls :: Access The Instance Returned By Details Page?

Jan 28, 2010

I have this specific task: I have a contacts table, and when users view a specific contact in details page I want to display a button in the page (doesn't matter anywhere, but inside the detailsview control next to the "edit" hyperlink is better), when it's clicked I want to grab all the info of this contact instance and write it to Response so user can save it through the save file dialog. So far I have two problems1. How do I access the contact? it's displaying on the page but when I tried detailsview.dataitem it returns null, e.result in the datasource selected event handler also returns null...2. I can get the button (outside the detailsview control) to trigger the file download dialog, but how do I achieve the same thing if the button is placed inside the details view which is in turn inside a updatepanel?

View 1 Replies

MVC :: Access HTTPContext And Session From Custom Base Controller Class?

Jan 13, 2010

I built a base controller class inherits from Controller class to add some custom behavior to all controllers which will inherit from this base class.

My issue is when I try to access HTTPContext and Session objects in my custom base class, they are always null.

Am I doing something wrong or need missing something?

My custom base class definition:

public class ApplicationControllerBase : Controller

controllers classes definition:

public class HomeController : ApplicationControllerBase

using ASP.NET MVC 1, .NET 3.5.

UPDATE:

It seems the issue is I try to access HTTPContext in the constructor while HTTPContext is not ready yet, I tried it in the OnActionExecuted event handler and it works fine.

My question is what is the best place to access Session object in my custom controller class, that will guarantee executing my code with all controllers.

View 3 Replies

MVC :: Access Values In Text Boxes(generated In View) From Controller

Feb 28, 2011









View 1 Replies

Architecture :: Should DAL Reference Added In Presentation Layer? How To Access The Instance Of Table In Presenta

Mar 3, 2011

I creating 3 tier arch wpp in VS 2010. I added the BusinessAccessLayer refernce in Presentation Layer. and I created DataAccessLayer[DAL] and ORM [DBModel.DBML]. when i try to create the instance for the Table in presenation layer[default.aspx], The Table name is not shown.After adding the DataAccessLayer refernce in the presentation layer, the table name[MM_User] instance are shown.Is it the right method [Adding the DAL refernce in Presenation Layer]? If not, whats the solution for for accessing the instance of the tables[MM_User].Is it related to the Creating the DataContextWrapper class in DAL?

View 5 Replies

Visual Studio :: Vs Asp2008 Instance Cant Recognize SqlExpress 2008 Instance On Machine

Feb 6, 2010

vs asp2008 instance cant recognize the sqlExpress 2008 instance on my machine

I have wonder if you could try to help me with the fallowing issue:When trying to add a new sql server connection (local or remount) from VS(visual studio) 2008 express - on the add connection dialog

box: server name: are Empty!!
The vs couldn't point to any database, like dont recognize the sqlExpress 2008 instance i got on my machine.

1. Have tried to "play" with sa property's(from sqlS: Databases: security: login tree folder) and with the sql

s windows service: stop and restart
2. And so with the target db.
3.

On the services.msc
The sql server express the status is started.
The sql server agent status is disabled and don't have the option to start.
The sql server explorer status is disabled and don't have the option to start.

4. And so reinstalled the asp.

View 2 Replies

Forms Data Controls :: Cannot Access Header Row Error / Object Reference Not Set To An Instance Of An Object

Jul 2, 2010

I tried to get the heade row text with the following code, but it failed.

[Code]....

Error returned was "Object reference not set to an instance of an object." on this line:

[Code]....

View 3 Replies

Forms Data Controls :: How To Access A LinkButton Inside A Repeater/Object Reference Not Set To An Instance Of An Object

Jan 16, 2010

why I get this error:

Object reference not set to an instance of an object.

when I try to access a LinkButton inside a Repeater as follows:

[Code]....

[Code]....

View 4 Replies

MVC :: Out Of The Box MVC2 Controller / Delete Controller Is Refusing To Return Any Class Information

Nov 6, 2010

my MVC2 delete and only my delete controller is refusing to return any class information. Its really similar to my edit function and the views are all auto-generated so I don't see the problem.

Function Delete(ByVal id As Integer) As ActionResult

View 4 Replies

How To Access The Instance Variables Of One Class To Be Used In Another Class

Sep 15, 2010

Suppose we declare and define the variable in one class let say FirstClass and we want to use that variable in another class let say SecondClass which is outside of FirstClass .how to do this?

View 2 Replies

MVC :: Pass Parameter From Controller To View And Back To Another Controller?

Aug 16, 2010

I have a simple model where a Person has Gifts. I have a view which is a list of Gifts belonging to one Person.

My problem is with the Create action for a new Gift. I want it to default to the PersonID that we are already viewing the list of Gifts for. I tried simply passing the last PersonID (they are all the same)

Html.ActionLink("Create New", "Create", new { id = Model.Last().PersonID }) which works fine if there is already at least one Gift for that person but if this is the first Gift I don't have a value.

My Gift List controller knows the PersonID I want to pass but the view doesn't.

How do I pass this PersonID from my Gift List controller to my Gift Create controller via the Gift List view? Or is there a better way to do this?

View 2 Replies

MVC :: Session Vs TempData / How To Persist Values From Controller To Controller

May 30, 2010

I have a filter on my MVC web site. I display some records in a few different controller actions but when moving from one action to another I want to apply those filter values.

How can I persist values from controller to controller?

Should I use Session? TempData?

I am using Structure Map for IOC.

Maybe I could have a class that contains a Property for each Session Value that I use in my application and inject it on the controllers that need session?

View 10 Replies

MVC :: Get The Current Action / Controller Name In A Controller Or Class?

Mar 14, 2011

How do you get the current action / controller name in a controller or class?

i can't show it in my view but that's not what i want.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved