I am set up a series of pages like so...Page 1: User is presented a series of checkboxes. Each checkbox represents a group.<User makes selection and submits form, Controller validates input and send selected list to next action>Page 2: User is presented a series of checkboxes of items within the groups he/she selected in step 1.<User makes selection and submits form, Controller validates input and send selected list to next action>
I have one controller that takes a username and pass and checks against a database. IF the user is authenticated, I want to call an overloaded action on another controller.
My end goal is to authenticate a user against an old table from a MySQL db (I have this part working). Once the user is authenticated, I would like to be able to "automagically" forward the person to the built in MVC registration page but I would like to populate some fields in the view using data obtained from the first controller (the old databse info).
When I try something like what I have below I get an error about the Register() methods being ambiguous. I've also tried using the [ActionName("Register2")] attribute but then the error returned says it cant find a method named Register2.
i want to use MVC 2 actions to pass JSON data to a 3rd party application via a URL.The URL will be in the form of http://www.abc.com/controller/action..I am using JSonResultHow can i test the output of this URL to ensure the JSON is properly formed..
In above senario in both cases same route "ABC" is called eventhough i have clicked on second Html.routelink. can anyone solve this issue ? how can i route according to route name instead of number of parameters?
I am getting an exception that child actions are not allowed to perform redirect actions. Although I can understand that this might is true in most situations I do believe that the framework might allow this to pass when a Child Action is calling another child action like in this example:
I have this code in my CountryController (I compacted it a bit but the main concept remains that I have a controller with Child Actions only):
[Code]....
This exception is being thrown:
Server Error in '/' Application.
Child actions are not allowed to perform redirect actions. Description:An unhandled exception occurred during the execution of the current web request. Review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Child actions are not allowed to perform redirect actions.
I need to log every user-action taken on a database using the username of the person logged into my ASP.net application as the identifier in the log. What is the easiest way to do this? I guess that for every method call to my data access layer I need to log the parameters of that call and the username and then call a new "log event" method that writes the details of the call to a table. Am I on the right track?
quick question: I have a view on my HomeController which is used to create a new 'model'. This view posts to a different controller to keep things tidy. The problem I am having is when I enter invalid details into the form, the rules I specified never seem to make it back to the original view and thus my validation messages or summary never get populated. Is there a way around this because I am using a view model with two IEnumerable lists in it.
In my actions, I want to pre-load the User object and set some other properties, all BEFORE the action loads. I know there are events where I can do this, but how will these objects that I set be made available in my controller's actions once the filter fires and execution is now at the action level?
example:
public actionresult SomeAction() { string username = this.CurrentUser.username; }
View on a button I have many different actions. So how to align them with the corresponding action in the controller. Means I want to know how many actions a View.For example, in the registration page.I have a button-Register and Login button. In the controller I have a registration action, an action Login. So how can I distinguish between those actions.
Like most web applications you have a method that gets called when you log in. There are a few things that may need to get done when logged in and over time this may increase. eg. logging, welcome emails, maintenance. Should events be used to do this or is there a better way?? I'm using C# and ASP.net MVC. Update This is already in its on Service Layer class. eg.
public void Login(User user) { SetAuthCookie(user); LogLogin(user, true); SendEmails(); }
Is there a way to easily passed around an ID between controller actions on the same controller?I.E. I have an Index action which takes an ID parameter, and when a user creates a new post I would like them to go back to the index page with the same ID.Currently I am just passing it around in my view model, but it seems real cumbersome and I was wondering if there was a better way to do this?
I'm trying to create a log that would keep a history of changes for a given item. For example on [HttpPost] Edit page I would log a change for a given article. So i've created a filterAttribute that would execute once the Edit action has completed successfully:
public class LogAttribute : ActionFilterAttribute { private int type; [code]...
I tried this:
filterContext.ActionDescriptor.GetParameters()
but this only returns "strings" as a parameter. "objectId" however is stored in a hidden field on the edit page.
routes.MapRouteLower("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" });
However, beacause of SEO I would also like to filter not by id but by name. Something like: Product/Show/RedBall instead of Product/Show/2345 And if RedBall is not unique what would be a good approach to do this? Maybe start using the following: Product/Show/2345/RedBall Using Id and Name as parameters in the actions?
// // GET: /TaxStatements/CalculateTax/{prettyId} public ActionResult CalculateTax(int prettyId) { if (prettyId == 0) return Json(true, JsonRequestBehavior.AllowGet); TaxStatement selected = _repository.Load(prettyId); return Json(selected.calculateTax, JsonRequestBehavior.AllowGet); // calculateTax is of type bool }
I had problems with this because when using it in jquery functions I had all sorts of error, mostly toLowerCase() function failing.
So I had to change the actions in a way that they return bool as string (calling ToString() on bool values), so that thay return "true" or "false" (in the qoutes) but I kinda don't like.
My setup project installs web site and executes some custom actions using a class library. That class library is copied to bin folder of the web site, and after that IIS tries to load it even though it isn't needed by the web site any how. How to prevent the class library from loading? Maybe it is possible to copy it to another directory instead of bin? Or maybe the web.config can be configured in such a way to prevent that class library from loading?
I've reated a project containing 15 pages , (inculding one for logging in )well , i've noticed that actions located in the page_load function are not executed! (i've tested with changing the text of a label and a text box) and it's in all pages except the authentification page!i've read tht it's probably due to the DATETIME class used in pages. but is there any other explanation? or is there any way to fix the problem
My controller has three actions: Inroduction, Index and category. In my master page I have a text box and a search button. The general idea is that the user reaches the Introduction view, then types text into the textbox and clicks the search button. He then sees the Index view, while the query string holds a value by which the data the user sees is filtered. the user can choose a category and then he is redirected to the category view. How can I maintain the query string field and value (let's say "?cities=1,2,3") when I move between the actions Introduction, Index and category ? I'll just point out that the query string value will change if the user enters new text in the textbox.
so on my view its going to Update Actionresult on button click.. itsdoing fyn.. but is there any way that we can do two action same time on Beginform.. that is Frist it need to go to GetStudentInfo, Home and then Immediatly Update, home?bec to update each and every time I need StudentInfo and then update
I wish to be able to place a System.Web.ActionFilterAttribute on an Action Method and override the OnActionExecuting method to insert business logic which determines if the Action should be fulfilled. Can the ActionExecutingContext be used to cancel the executing Action Method and do one of the following:
Send an HTTP Status Code (and the corresponding <customError> page).Execute a different Action Method within the same Controller.
When running it looks like this: (Image Link) When I click on the Add New link in the Users section I get this: (Image Link) When I click on the ** Move Company** link in the company details section I get this: (Image Link)
Now, everything is working good so far - until I click on a node in the tree within my modal popup. It then exits the popup and I don't want it to. I am not good at JQuery (the JQuery above is not mine) and I tried to suppress the node click events with the commented out code above but all that did was suppress the entire popup from showing!
what I can do to suppress the node clicks from firing the JQuery close routine for the modal popup?
Been browsing these pages for a while now and finally decided to say hi!I read about having an "Application controller" as mustinherit class for the actual controller to set content for the master page. But what I would like to do is to set some content to Master based on which actions are called on the controller.
For example.. /Backend/A1 ... "Help content nr1 to master page" /Backend/A3 /Backend/B1 ... "Help content nr2 to master page" /Backend/B10
And so forth. Ofcourse I could do this the "easy" way by just adding some clip on each of the actions. But I was wondering if there is a smarter way to do it. To check on the application controller which action is being called and select the "helpcontent" based on that to the Master.