asp.net-mvc-controller

Should controller lifestyle always be transient in Windsor configuration for ASP.NET MVC?

感情迁移 提交于 2021-02-18 12:22:31
问题 I ran into a problem where I had an Html.DropDownList in my view that would postback the selected value the first time I submitted the form, but each subsequent postback would only post data from the initial postback. So I added lifestyle="transient" to the component element where I had configured my controller for castle windsor, which fixed the problem, but of course made postbacks take longer since a new controller was being instantiated per request. Given the information above, what

ASP.NET MVC Core Tag Helper Issue

*爱你&永不变心* 提交于 2021-02-08 10:25:18
问题 I am having an issue using tag helpers in a form element. When I choose the "GET" HTTP method, the parameter for my Edit method in my Item controller won't get filled by the "hello" argument. However, when I choose the "POST" HTTP method, the parameter is filled correctly with "hello". Why is this happening? <form asp-controller="Item" asp-action="Edit" asp-route-item="hello" method="get"> <input type="submit" /> </form> And here is the controller: [HttpGet] [HttpPost] public IActionResult

ASP.NET MVC C# Get controller and action name in class

可紊 提交于 2020-01-23 07:23:17
问题 I'm pretty much new to StackOverflow so please forgive any signs of my ignorance. :) I have a somewhat minor issue with an MVC application in Visual Studio 2010 (Controllers written in C#). I want to create a method which generates an application action history and for that purpose I want to get the name of the controller and action that are used each time. Unfortunately the first letter of the string which holds my controller name is always missing. I used this code: string url = HttpContext

Inheritance of Authorized Roles in controller classes

蹲街弑〆低调 提交于 2019-12-22 11:33:04
问题 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 abstract class ControllerAuthorities:Controller { } [Authorize(Roles = "Admin")] public abstract class AdminController:ControllerAuthorities { } [Authorize(Roles = "Employee")] public abstract class EmployeeController:AdminController { } [Authorize

How to achieve a dynamic controller and action method in ASP.NET MVC?

青春壹個敷衍的年華 提交于 2019-12-17 08:49:11
问题 In Asp.net MVC the url structure goes like http://example.com/{controller}/{action}/{id} For each "controller", say http://example.com/blog, there is a BlogController. But my {controller} portion of the url is not decided pre-hand, but it is dynamically determined at run time, how do I create a "dynamic controller" that maps anything to the same controller which then based on the value and determines what to do? Same thing with {action}, if the {action} portion of my url is also dynamic, is

MVC Ambiguous Action for Login

被刻印的时光 ゝ 提交于 2019-12-13 15:41:59
问题 I've got an ASP.NET MVC4 website (using vs2012) that allows users to login by clicking the "login" link. I'm getting the infamous error: The current request for action 'Login' on controller type 'AccountController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Login() on type MyProject.Controllers.AccountController System.Web.Mvc.ActionResult Login(MyProject.Clients) on type MyProject.Controllers.AccountController I've checked a bunch of links on here,

MVC No Add Controller Menu or Scaffolding Menu

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 07:44:45
问题 Just wondering if any of you has experience the same trouble, since I downloaded the Visual Studio Express 2013 For web, the "Add Controller or Scaffolding" never appear in the menu when I created a new project. I have updated the MVC 5.2.2 still no luck, I have Added the GUID E3E379DF-F4C6-4180-9B81-6769533ABE47 still not showing up. Anyone who answer very much appreciated, Thank you 来源: https://stackoverflow.com/questions/26962562/mvc-no-add-controller-menu-or-scaffolding-menu

Cannot add controller in ASP.NET MVC project

孤街醉人 提交于 2019-12-10 10:54:28
问题 I'm trying to add a controller in my ASP.NET MVC project. I am using Entity Framework Code First (5.0), and when I right-click the Controllers folder in my project and selecting Add Controller : After selecting MVC controller with read/write actions and views, using Entity Framework and other settings, I get this message: There was an error generating '{0}'. Try rebuilding your project. Update Seems that the special constructor I added to the DbContext caused the problem. After commenting out

keeping asp.net mvc controller size down

廉价感情. 提交于 2019-12-09 18:22:25
问题 I have a Controller. "OrderController". Currently it's 1800 lines. I like to reduce the size. I'm using static helper methods which is fine but i'm using ninject to call my repositories so don't have access to the repositories in the static methods without passing the properties in. What are some good approaches for reducing controller noise? 回答1: How to get a Thin Controller Refactor reusable functionalities that can apply to multiple types of output to ActionFilters . Consequence: Less

MVC3 – ViewModels and controller functionalty: suggested design patterns

橙三吉。 提交于 2019-12-07 18:33:38
问题 I have built a simple MVC3-based ticket entry site for a less-than-usable call center application and am attempting to refactor my prototype to better adhere to design patterns partly to make it more maintainable going forward but mostly as a learning exercise. The user-facing view is a form consisting of basic user information in addition to a few panels allowing selection of various resource types. Each resource type (hardware, software, etc) is displayed in the same way: using dual,