MVC :: Determine Which Action Invoked Particular Action?
Nov 12, 2010
I have a controller with a bunch of actions as such:
[Code]....
I'm looking for a way to find out which action invoked the other: for instance, when redirecting to Action1, I need to know whether it is coming from clicking "next" button at Action0 or clicking "back" button at Action2. This is is to avoid performing Action1 twice (My app is like a wizard, if I click back button at Action2, I don't want to execute Action1 again).
View 1 Replies
Similar Messages:
Jan 12, 2011
I am not sure what is going on but even though I am invoking a different controller with action a particular FooController's Index action is being invoked all the time. The Global.asax file has setup the FooController to be the default controller.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "FooController", action = "SomeAction", id = UrlParameter.Optional } // Parameter defaults
);
}
View 1 Replies
Apr 8, 2010
Im fairly new to Asp.Net MVC. I spent some time to fix this but I get it to work. What I have is a:
QuestionController : Controller
{
public ActionResult Add()
{
//do stuff
}
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Add(int roomuid)
{
//do stuff
}
}
now in my view i have : <a href = "/Question/Add">click here </a> The strange thing is that public ActionResult Add(int roomuid) is called and not Add() without get parameters. Even if I change the [AcceptVerbs(HttpVerbs.Get)] to [AcceptVerbs(HttpVerbs.Post)]
View 1 Replies
Mar 7, 2011
I'm writting an application where I want to execute some code before a controller is invoked, even before the controller is created. I would like to somehow hook into the request processing as early as possible after the request is parsed and the RouteData is available. I've tried to hook in by handling the BeginRequest event but at this point there is no RouteData. Is there another place I can look for the area when BeginRequest delivered or is there another place in the request processing pipe that I can hook in to find the area before my controller is invoked.
View 2 Replies
Aug 9, 2010
I have a weird issue. I loaded a page using "LoadMyPageController" and there is an ajax_submit_button1 which can be used submit the page. Also there is another ajax_submit_button2 to print the page. This button submits the view model of the page as a whole to the "PrintController" which has a "PrintData" action.
Now when I hit the "ajax_submit_button2", my PrintController.PrintData is not invoked. Instead when I check my fiddler tool the request is made as [URL] which is an invalid URL. I have contructed my ajax_submit_button2 in such a way that it should invoke [URL] But I don't know why LoadMyPage controller is present in my URL. By any chance does asp .net MVC decides that it will take a default controller on its own if it can't find the controller action for any reason. The code is a kind of tightly coupled so can't post it. I want to know if anyone experienced a problem like this.
View 1 Replies
Mar 11, 2011
Where can I put some code that will be executed before any controller action is executed? I'm trying to replace default ASP.NET Session and I need to do this before any controller actions take place: get the cookies collection and check if I have new visitor with no cookies - than I'd add new "session ID" cookie that will than be available to the controllers. Otherwise (if there already is some "session ID" cookie) I will not do anything.
View 4 Replies
Aug 27, 2010
The page I'm editing had three tabs, each tab contains a diffrent grid view which is populated by a search box with in the tab. Each row in the grid view has a check box. When a print button is pressed all records with a tick in the check box should be printed off. Then page then reloads but some of the content is missing due to the way the page has been coded. This is becuase some of the code is only called when the tab is clicked not on postback. Is there anyway that I change the following code so that it's called after postback? These are the functions that are causing the most problem.. I need them to be loaded for the correct tab on postback.. I can't do it for all three as the code takes forever to run in that case.
AddActionsToGridView(gvGlobal);
AddCheckboxesToGridView(gvGlobal);
{
if (tabconConsignments.ActiveTabIndex == 0)
{
dtGlobalIDConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "GlobalID", "", "");
//Global ID Tab
gvGlobal.DataSource = dtGlobalIDConsignments;
gvGlobal.DataBind();
//Actions
AddActionsToGridView(gvGlobal);
AddCheckboxesToGridView(gvGlobal);
}
else if (tabconConsignments.ActiveTabIndex == 1)
{
dtCreatedDateConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "CreatedDate", "", "");
//Created Date Tab
gvCreationDate.DataSource = dtCreatedDateConsignments;
gvCreationDate.DataBind();
tbCreationDateSearch.Text = "";
//Actions
AddActionsToGridView(gvCreationDate);
AddCheckboxesToGridView(gvCreationDate);
}
else if (tabconConsignments.ActiveTabIndex == 2)
{
dtAccountsConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "Account", "", "");
//Account Tab
gvAccount.DataSource = dtAccountsConsignments;
gvAccount.DataBind();
AddActionsToGridView(gvAccount);
AddCheckboxesToGridView(gvAccount);
}
if you want me to post any more code or any more info it's been a hard one for me to get my head around so I might of missed something out.
View 2 Replies
Jul 13, 2010
I'm stuck with a problem of which I can not imagine I am the first person having to deal with it. Yet, Google comes up with nothing useful and neither does SO, so here I am. I'm using ASP.NET MVC1 with a sitemap. Using an html helper I create a navigation menu that highlights the current selected option in the Site.Master page. Common scenario and easily done by using:
foreach ( SiteMapNode subnode in node.ChildNodes) {
if (SiteMap.CurrentNode == subnode) { //got ourselves the current here }
}
That's all fine and dandy, however, my problem is that I have 1 controller with multiple actions. Consider the following scenario:
Accounts
* clients
* suppliers
* maintainance
They would all be in my AccountController, doing a search that is identical but with a different AccountTypeId value. When I read the SiteMap.CurrentNode value it gives me merely the info that I am using the AccountController, but not which action I called. I've tried a whole bunch of things but I can not get the action that was requested. I hope I gave enough info there to give you an idea of the scenario. If you need anything else, let me know.
View 2 Replies
Nov 29, 2010
I'm implement Comet in Asp.net MVC, I used timer to keep Async request in server, Async request will complete when timer elapsed 1 minute and response to client (to avoid 404 error) and then reconnect to Async Controller. I also wanna execute some Synchronous action during Async request was holding, but the problem is: When an Async action was executed and hold by using timer, the Sync Action wasn't called until Async action (comet long-live request) completed. I did test with firefox 3.6 many times, but the result is the same, so strange, Do you know why ? I have a sub some questions : To implement comet, using timer (response after some minutes elapsed) or thread (response after several time sleeping thread) to hold async request, which is better?
View 1 Replies
Mar 23, 2011
I am desiging a master and details page from a search page..user can search for something and I need to display the result in jqgrid if the result has more than 1 row or record.. if the result is just one record then i have to directly send then to details page by skiping grid page... I do have an action method for results page and one more action method for Jqgrid data..i am trying to check the row count for the database result and trying to redirect to details action results..but its not working at all..and showing an empty jqgrid..
[Code]....
View 9 Replies
Apr 29, 2010
Lets say I have a simple controller for ASP.NET MVC I want to test. I want to test that a controller action (Foo, in this case) simply returns a link to another action (Bar, in this case).How would you test TestController.Foo? (either the first or second link)
My implementation has the same link twice. One passes the url throw ViewData[]. This seems more testable to me, as I can check the ViewData collection returned from Foo(). Even this way though, I don't know how to validate the url itself without making dependencies on routing.The controller:
public class TestController : Controller
{
public ActionResult Foo()[code].....
View 1 Replies
Jun 12, 2010
My httppost action doesnt seem to have received my model. The code is below;
[Code]....
i put a breakpoint on the line; return RedirectToAction("Error", "Dashboard"); and i found that appQualif carried no values whatsoever from the form i submitted..
View 5 Replies
Jun 30, 2010
I've been using Html.Action("ActionName", "ControllerName") to invoke child actions across controllers without needing to have the view in ViewsShared. This has been working great for displaying things like session or cookie information.
Instead of just accessing cookies, I would like to pass additional parameters to Html.Action("ActionName", "ControllerName") so the action can execute different code based on the the data passed to the original view.
Should I be using a different method to pass parameters to a child action in a different controller?
View 1 Replies
May 20, 2010
I'm trying to add file upload functionality to a page. I've got a form that posts the selected file to a controller with a 'savefile' method. But if I don't add a get version of 'savefile' I'll get a 404 error. Here is the form code which is presented on the Index page:
[Code]....
And here is the controller code:
[Code]....
Intuitively I don't think I should need a GET version of SaveFile but if omit it I get a 404 error when the form posts. Why should I need a GET version of SaveFile when all I want is to post a form and save the file?
View 4 Replies
Jun 21, 2010
Does any one know how to dynamically add ActionFilter to an Action?
View 3 Replies
Mar 14, 2010
I'm a newbie into MVC and I am like only on chapter 7 in ASP.NET MVC Unleashed so be easy with m
[Code]....
how do I tell Create Button to send to an Action named Create and to Edit to an Action named Edit on the same form?I guess it is possible on ASP.NET MVC if it is possible on ASP.NET Webforms
View 6 Replies
Mar 31, 2010
I have a view MemberProfile like this
<% using (Html.BeginForm()
)
{ %>
<fieldset>
<p>FirstName :<%=Html.TextBox("FirstName", Model.FirstName) %></p>
<p>Last Name : <%=Html.TextBox("LastName", Model.LastName)%></p>
[code]...
View 1 Replies
Feb 3, 2011
I have a page with three partial views. On the first ascx, I want some data posted when a user clicks on "submit" button, and send that data to another POST action "search" and search the db with that data, the final output should be the view returned by "search". How do I do this?
View 3 Replies
Aug 27, 2010
I have the Index action method calling a method that itself is an action method.
Example :
[Code]....
What to do in this case ?
View 10 Replies
Sep 28, 2010
I have two actions with the same name:
[Code]....
I think everything clear here. But I don't like that parameter int k which I never use and which I pasted in order to create another function which will be launched when some data was posted to that action.
View 2 Replies
Jul 29, 2010
I have a problem, whereby if I browse to a page using a url of the form: site/home.mvc/Index where Index is an action on the Home controller, my page displays as I would expect.
However, if I browse to site/home.mvc the page loads, all except for my images which are replaced by red crosses.
View 3 Replies
Oct 28, 2010
there is an Account/SignOut link in Home/Index page,if i click this link ,in action SignOut,how to get the preview action Home/Index?
View 2 Replies
Mar 20, 2010
i'm creating a mvc application and i'll use under subdomain like http://myapp.mycompany.com
This subdomain is pointing to app subdirectory, but my actions are always generated with applicationPath (subdirectory) like:
http://myapp.mycompany.com/myapp/Home/About
// I want just this without additional paths
http://myapp.mycompany.com/Home/About
Is there any configuration related to this?
Is this the correct way to generate links?
<%= Html.ActionLink("About", "About", "Home") %>
View 2 Replies
May 6, 2010
I can get the current action name by using the following code
var currentActionName = ControllerContext.RouteData.GetRequiredString("action");
but is it possible to get the previous action name as well?
View 1 Replies
Feb 7, 2010
I have 2 views for a input operation in my application.
The first view (lets call it view1) submits a form. Based on the form some operations on database is done and second view(View2) is returned with some other data from the database as a model.
controller action code :
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult View1(FormCollection fc)
{
//database ops to fill vm properties
View2ViewModel vm=new View2ViewModel();
return View("View2", vm);
}
Now, since I return a new view and not a action redirect the url is still http://url/View1 but everything works as it is supposed to.
The problem:
When I submit the form in View2 it calls the View1 action method, not the View2 action method. Probably because the url is still View1. What can I do to call the action View2
View 3 Replies