MVC :: Renderaction Calls Wrong Action Method?

Nov 19, 2010

I'm struggling with renderaction, the problem is that it calls the wrong action method on my controller.On my "Users" controller there are two action methods called edit, one for get and one for post requests:

public virtual ActionResult Edit(int id)
{
//return a view for editing the user

[code]...

View 3 Replies


Similar Messages:

RenderAction Not Finding Action Method In Current Controller In Current Area?

Mar 15, 2010

I'm creating an ASP.NET MVC 2 (RTM) project that uses areas. The Index action of the Home controller of one area needs to use RenderAction to generate a sub-section of the page. The action called is also defined in the same Home controller. So the call should just be:

<% Html.RenderAction("List") %>

However, I get an exception:A public action method 'List' was not found on controller 'RareBridge.Web.Areas.Events.Controllers.HomeController'.

Note that I'm not in the "Events" area! I'm in a completely different area. If I remove the "Events" home controller, then the exception still occurs but names a different controller (still not the one I want it to call).

I've also tried providing the controller name and area to the RenderAction method, but the same exception occurs. What is going on here?

BTW: I am using Autofac as my IoC container

View 2 Replies

Using A RenderAction Method Throws An Exception

Dec 29, 2010

i have this (simple) code

<% Html.RenderAction("Version", "Generic"); %>

in my masterpage of my asp.net mvc 2 app. This method returns the version of the application.

i also have this code in my controller:

class GenericController : BaseController
{
[ChildActionOnly]
public string Version()
{
try
{
string assemblyFile = Assembly.GetCallingAssembly().FullName;
FileInfo fi = new FileInfo(assemblyFile);
string version = fi.LastWriteTime.Year.ToString( ) + fi.LastWriteTime.Month.ToString() + fi.LastWriteTime.Day.ToString();
return version;
}
catch (Exception e)
{
return "1.0";
}
}
}

Now i get this error:
Execution of the child request failed. Please examine the InnerException for more information.

and the innerexcpetion is:
{"The controller for path '/Account/LogOn' was not found or does not implement IController."}

What i was thinking is that maybe the code can't execute because the user is not logged on yet, and tries to redirect to the logon method etc.

So the first thing i was thinking is to grant access in the web.config (like i do with the directory that has the css and images in it, it should also be accessable when you're not logged on:

<location path="Content">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>

but what is the path for this (version) method ?

(or maybe there is another reason for the excpetion.

View 1 Replies

MVC :: Action Method Returning An ActionResult Used In A Action Method?

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

Get Html.RenderAction To Call The Get Method On A Post?

Sep 21, 2010

After rendering a view on a Post, a call to RenderAction inside the view will call for the Post method. Is there any way to specify I want to call the Get method instead of the Post?

View 1 Replies

MVC :: Url Becomes Wrong When Using Id On Action?

Jan 12, 2010

I have the following in my JQuery code:

icon.image = "../Contents/Image/GoogleMapMarker_Icon.png";

This works fine when I am on the url:

http://localhost:65125/Center

But if I pass an Id to the action and get the following url:

http://localhost:65125/Center/3

The image is not loaded and I get a 404 error. I was checking with with Firebug and I get:

http://localhost:65125/Center/Index/Contents/Image/Marker_Icon.png

Instead of:

http://localhost:65125/Contents/Image/Marker_Icon.png

View 7 Replies

MVC :: Redirect Action Not Working In Jqgrid Action Results Method

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

MVC :: Wrong Action Invoked In Controller

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

MVC :: Partial View Contains A Link That Calls An Action Via Ajax?

Nov 27, 2010

I have a view that renders a few partial views. Each partial view contains a link that calls an action via ajax. The result from the action is used to fill a div. Because I use the same partial view a few times, it always renders the div with the same id. In asp.net, we have something like naming container, that assures that each element has unique ID. How can I make IDs in a partial view unique ?

View 1 Replies

C# - Difference Between Url.Action And Html.RenderActionLink And Html.RenderAction

Apr 12, 2010

Whats the difference between Url.Action and Html.RenderActionLink in asp.net mvc?

View 1 Replies

MVC :: RenderAction() Ignores Model Validation, RenderAction() Does Not?

Jun 4, 2010

I'm using MVC 2 and MVC Futures 2.0.50217.0.

I started with a view which repeatedly calls RenderAction(...) to include some external content implemented by another controller in my application. This is from the containing view:

[Code]....

The subModel objects are instances of the model for the MyController.MyAction view which has some Data Annotations validation attributes upon it. MyController.MyAction checks the model state is valid before it renders its view and chooses a view appropriately. This works fine.

However, if I use the MVC Futures' strongly typed helper to call RenderAction like so:

[Code]....

...then the validation is not performed. Or at least, the model state does not indicate that the model is invalid.

View 7 Replies

Difference Between Html.RenderAction And Html.Action?

Jun 2, 2010

Does anybody know what's the difference between Html.RenderAction and Html.Action?

View 2 Replies

State Management :: Data Being Saved To Wrong Table In Wrong Instance Of Sqlserver Of Wrong Database?

Aug 1, 2010

I have a weird thing happening. I have two identical databases installed on one virtual machine but under two different instances of SQLServer. For some reason, periodically when saving from one it will save to the other instead. Using debug, I have verified that the connection string is correct and when the item saves, it still saves to the wrong database.I use session variable, and am of the belief that it might have something to do with it...and t hat when I go from one to the other it is still getting the connection string form the other for some reason.To make sure that it isn't a problem, I make sure that I completely close out one database before opening the other in a new IE window.I assume that when I completely close out an internet explorer window that it abandons all session states. Is that true?

View 7 Replies

AJAX :: Asynchronous Calls To Same Method?

Mar 12, 2010

I am relatively new to asp.net. In My asp.net website, i have a method GetData(int id) which is called Repetitively, depending on id count, GetData is desinged to get data from sharepoint and sql server both. if the Id count is high say =10, my page load time increases because GetData is called 10 times and the page load time keeps adding up. so I want to ask, is there any way that this GetData() be called asynchornously or by the use of some thread, so that my page loads faster.

View 2 Replies

ObjectDataSource Calls Update Method With Old Values?

Jun 20, 2010

i have an instance of ObjectDataSource with specified update method. But on update i have an old values(previously set in gridview) in method - they are not updating.

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="DeletePayment"
InsertMethod="InsertPayment" SelectMethod="GetPayments" TypeName="CostsReportControl.Models.Payments"
UpdateMethod="UpdatePayment" OldValuesParameterFormatString="{0}_old">
<SelectParameters>
<asp:Parameter Direction="input" Type="string" Name="sortExpression" />
<asp:Parameter Direction="input" Type="string" Name="sortDirection" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="GetList" TypeName="CostsReportControl.Models.PaymentTypes">
</asp:ObjectDataSource>

my update method

public void UpdatePayment(int Id,string Fullname,DateTime Date, string Sum, string PaymentType, string RecordInfo,int Id_old)

View 2 Replies

FindControl Getting Wrong Control In My Recursive Method?

Mar 11, 2011

I use the following method to find a control on an asp.net page recursively:

/// <summary>
/// Searches recursively for a server control with the specified id parameter.
/// </summary>[code]...

I hit a problem because it was returning the wrong control. I tracked the problem down to the standard FindControl method, and fixed it by checking that the id of the control returned did actually match the one requested like this:

foundControl = start.FindControl(id);
if (foundControl != null && foundControl.ID == id)
return foundControl;

My question is why does start.FindControl(id) ever return a control that does not match the id requested?

View 1 Replies

Speed Up A Web Service For Auto Complete And Avoid Too Many Method Calls?

Jun 11, 2010

So I've got my jquery autocomplete 'working,' but its a little fidgety since I call the webservice method each time a keydown() fires so I get lots of methods hanging and sometimes to get the "auto" to work I have to type it out and backspace a bit because i'm assuming it got its return value a little slow. I've limited the query results to 8 to mininmize time. Is there anything i can do to make this a little snappier? This thing seems near useless if I don't get it a little more responsive.

[Code].....

View 5 Replies

AJAX :: AutoCompete Extender Calls Web Method (in Webservice) That Have Zero Parameter?

Jun 11, 2010

I have AutocompeteExtender control in my page.it calls web method (in webservice) that have no parameter I have two web methods in webservice Method 1Geist(string PreText, int Count){....}Method 2GetList(){.......}ethod 2 calls.I want to call method 1.

View 3 Replies

DataSource Controls :: Benefits Of Using ObjectDataSource Over Normal Method Calls?

Jul 6, 2010

In my application at some places we have used ObjectDataSource and at other normal method calls to retrieve data.My question is then what exactly are the benefits of using ObjectDataSource ?In the example below "CODE ONE" makes a call to the Business Layer and then Binds the results to the Grid abd "CODE TWO" is using ObjectDataSource to do the same.Then how is ObjectDataSource better?

SuitableApplicant sa = new SuitableApplicant();
IList<HD.Recruitment.SuitableApplicant> list = new List<HD.Recruitment.SuitableApplicant>();
list = HS.Recruitment.RecruitmentService.GetSuitableAppls();
GridView1.DataSource = list;
[code]....

View 5 Replies

Garbage Collection Of Strings Returned From C# Method Calls In Ascx Pages

Mar 18, 2010

For a web application developed on ASP.NET, we are finding that for user control files (ascx) we are returning long strings as a result of method calls. These are embedded in the ascx pages using the special tags <% %>When performing memory dump analysis for the application, we find that many of those strings are not being garbage collected. Also, the ascx pages are compiled to temporary DLLs and they are held in memory. Is this responsible for causing the long strings to remain in memory and not be garbage collected ?

View 2 Replies

Jquery Dialog Calls A Server Side Method With Button Parameters?

May 27, 2010

I have a gridview control with delete asp:ImageButton for each row of the grid. What I would like is for a jquery dialog to pop up when a user clicks the delete button to ask if they are sure they want to delete it.
So far I have the dialog coming up just fine, Ive got buttons on that dialog and I can make the buttons call server side methods but its getting the dialog to know the ID of the row that the user has selected and then passing that to the server side code. The button in the page row is currently just an 'a' tag with the id 'dialog_link'. The jquery on the page looks like this:

$("button").button();
$("#DeleteButton").click(function () {
$.ajax({

[code]...

The dialog itself is just a set of 'div' tags. Ive thought of lots of different ways of doing this (parameter passing, session variable etc...) but cant figure out how to get any of them working.Any ideas are most welcome

View 1 Replies

How To Get The URL Of An Action Method In .NET MVC Using AJAX

Nov 11, 2010

How can I make an AJAX call to retrieve the URL of controller's action method?

View 2 Replies

MVC :: How To Use AdditionalFields In Action Method

Jan 20, 2011

I've been using the new ASP.Net MVC 3 RemoteAttribute to send a remote call to an action method that had a single parameter. Now I want to pass in a second parameter using the AdditionalFields property:

[Remote("IsEmailAvailable", "Users", AdditionalFields = "InitialEmail")]

Where IntialEmail is a hidden field in the view. The action looks like so:

public JsonResult IsEmailAvailable(string email,string InitialEmail){//etc.}

When the view is rendered, the hidden field is populated, but when the Action method is triggered remotely, the value is an empty string.

I've seen elsewhere case sensitivity may be an issue, so I've ensured the Action method has the same case for both parameters.

View 2 Replies

MVC :: Explicitly Set Action Method?

Mar 11, 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.

[Code]....

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.

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.

View 1 Replies

Passing A Parameter To Action Method?

Sep 8, 2010

public ActionResult RenderMyThing(IList<String> strings)
{
return View("RenderMyView");
}

How do I pass in strings?

routes.MapRoute("MyRoute", "RenderMyThing.aspx", new { controller = "My", action = "RenderMyThing" });

Is there a way I could pass in strings here?

Secondly, how does ASP.NET MVC know that action is my action, and controller is my controller. Like I saw this in samples, and it does work, but isn't it just an anonymous object with no type?

View 1 Replies







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