es enrutable con la misma vista

I create a mvc3 application then I add a new tab in the Home Controller called Message (in the _Layout.cshtml of the shared folder), I include the following function into the HomeController.cs

public string Message(string msg)
    return "This is my message :" + msg + " to you";

I then can route with any of the following urls

> http://localhost:2554/Home/Message/message=some%20message
> http://localhost:2554/Home/Message
> http://localhost:2554/Home/Message/message

But I don't see the msg in the display. Why three of them results in the same view ? What should I add to make msg viewable then ?

preguntado el 10 de marzo de 12 a las 15:03

has probado http://localhost:2554/Home/Message?msg=some%20message ? -

1 Respuestas

add a route in your routetable if you want it to work via the methods you were showing above

_routeCollection.MapRoute("Message", "Home/Message/{msg}", new {controller = "Home", action = "Message", msg = ""});

respondido 10 mar '12, 16:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.