tags:

views:

421

answers:

3

Hi, I have a view that looks like this: http://whatever/Download/viaId/12345

And i would like to call the action

public void viaId (int Id)
{
    //Code 
}

when the page loads. Right now I only have the controller implemented and when I browse the url the parameter Id is null.

Do i need to create the view and call it through javascript ?

A: 

It sounds like you don't have a view, you just have a URL and an action.

You should create a view called "viaId" for your Controller to give to the user. The easiest way to do this is to right click on the action and click "Add View" (assuming you're using Visual Studio).

Additionally, the viaId method should probably return ActionResult instead of void.

mgroves
A: 

I think you just need to add the attribute

[AcceptVerbs(HttpVerbs.Get)]

public void viaId(int id) {}

Jack Marchetti
+1  A: 

Ok i got it solved. I did not have the parameter mapped on the RouteCollection. thanks for your suggestions

despart