Questions tagged [asp.net-mvc-controller]

The ASP.NET MVC framework maps URLs to classes that are referred to as controllers. Controllers process incoming requests, handle user input and interactions, and execute appropriate application logic. A controller class typically calls a separate view component to generate the HTML markup for the request.

The base class for all controllers is the ControllerBase class, which provides general MVC handling. The Controller class inherits from ControllerBase and is the default implement of a controller.

The Controller class is responsible for the following processing stages:

  • Locating the appropriate action method to call and validating that it can be called.
  • Getting the values to use as the action method's arguments.
  • Handling all errors that might occur during the execution of the action method.
  • Providing the default WebFormViewEngine class for rendering ASP.NET page types (views).
193 questions
4
votes
2 answers

Inheritance of Authorized Roles in controller classes

I've created controller classes to assist with Role authorization. I have a base class ControllersAuthorities, which is the highest level of authority. I have created the other classes to extend each base class. [Authorize(Roles = "Owner")] public…
4
votes
1 answer

How to handle lots of derived model with only one controller

I am using ASP.NET MVC and I have several model classes all derived from the parent object. I want to handle all of these models in one controller action since they are nearly identical with the exception of some data fields. I want to save them to…
DalekSupreme
  • 1,493
  • 3
  • 19
  • 32
4
votes
2 answers

Open URL in a new tab from MVC controller

How do i open an URL in a new tab / window from MVC controller based on success condition .Any way i can achieve it through the help of c# code without having to write javascript ?
Yoda
  • 319
  • 2
  • 5
  • 20
4
votes
3 answers

How to pass other form data along with MVC File Upload?

I am trying to implement File Upload in MVC. I have the following code which works. @using (Html.BeginForm("ActioName", "ControllerName", FormMethod.Post, new { enctype = "multipart/form-data" })) {
4
votes
3 answers

Hold a data object temporarily in MVC controller,MVC,MVC Controller temp storage

I have a object that i want to store for a moment. The object is in a controller for now, the controller will generate a view. A AJAX request is made from the view to next controller. For that moment i need the object previously stored. Previously,…
4
votes
2 answers

Is it possible to use an ApiController to call an Action written in a Controller?

I already have some Actions written in my Controllers but I'd need to use them as they were APIs. So I wonder if it's possible to call a single Controller Action in an ApiController. At the end I would like to have something like this: public…
xnr_z
  • 1,161
  • 2
  • 18
  • 34
4
votes
1 answer

Get an existing session in my BaseController constructor

In my Global.asax, i have this code in the Session_Start() : UserIntranet user = new UserIntranet(); user.Login = this.Request.LogonUserIdentity.Name.Split('\\')[1]; Session["user"] = user as UserIntranet; In my BaseController, i have this property…
Portekoi
  • 1,087
  • 2
  • 22
  • 44
4
votes
2 answers

ASP.NET Web API Routing in ApiController

I've been struggling with my routing for some time now and after a few days of trying to Google the solution without luck, I'm hoping someone may be able to shine some light on my problem. I have the following routes in my WebApiConfig: …
4
votes
1 answer

Why am I getting a 404 error when accessing a controller method in Ajax?

I have a controller ValidationController and it has a method called EmailExist I have an ajax call $.ajax({ type: "POST", url: "/Validation/EmailExist", data: { 'Email': $('#Email').val() }, success: function (result) { …
Pittfall
  • 2,751
  • 6
  • 32
  • 61
4
votes
1 answer

mvc httppost href parameters

I'm currently working in ASP.NET MVC 4 with EF 4.0. I have an unordered list with listitems. Each listitem contains a name and address and is clickable. Now I want to make it so that, when I click the listitem, I go to a new View. This view is…
3
votes
1 answer

.NET and Skinny Controllers/Fat Models Concept

I've been reading about "skinny controllers, fat models", and I see a lot of these implementations are Ruby and other languages. I don't see many implementations in .NET, though I'm not sure if that is because I can't find some examples of people…
Brian Mains
  • 50,520
  • 35
  • 148
  • 257
3
votes
1 answer

ASP.NET Core routing - mapping only specific controllers

Per documentation it seems like it's only possible to add either single routes, one by one, or add all routes in annotated (attribute routing) controllers DOCS: Routing to controller actions in ASP.NET Core Is it possible to add only all routes…
Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
3
votes
2 answers

MVC 3 Layout and Controllers

I m building a MVC 3 applications. The application should be able to display a different layout according to the sub domaine (ex: customer1.mysite.com -> layout1; customer2.mysite.com -> layout2; etc...) it will have also a layout for mobile and IE…
fred_
  • 1,486
  • 1
  • 19
  • 31
3
votes
2 answers

MVC 3 AJAX Function Post Two Times

I am using Visual Studio 2010 and MVC 3 with AJAX/JQuery. The issue I am having is that the code is posting something twice. It only happens when you post something, then do it again. Here is my JS: $(document).ready(function () { …
user634351
3
votes
1 answer

Access to a controller based on certain criteria

What is the correct way to restrict or allow access to a controller based on some criteria. I am having hard time to wrap my head around it... For Example, if i say somewhere (in db or some other persistence) that 'LocationA' can be served with…
Angloos
  • 755
  • 5
  • 11
1
2
3
12 13