1

This is my controller :

using System.Web;
using System.Web.Mvc;

namespace MvcMovie.Controllers
{
    public class HelloWorldController : Controller
    {
        // 
        // GET: /HelloWorld/ 
        public ActionResult Index()
        {
            return View();
        }
        // 
        // GET: /HelloWorld/Welcome/ 
        public string Welcome(string name)
        {
            return HttpUtility.HtmlEncode("Hello " + name + ", NumTimes is: 55 " );
        }
    }
}

This is my route :

public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

But whenever i pass the url : http://localhost:61114/helloworld/welcome/scott

My output is : Hello , NumTimes is: 55 instead of Hello Scott, NumTimes is: 55

1
  • 1
    because your route is id - not name Commented Jan 20, 2018 at 19:33

1 Answer 1

1

your parameter name should be id

or

your route should be {name} and name = UrlParameter.Optional

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.