How to pass special characters so ASP.NET MVC can handle correctly query string data?

Posted by labilbe on Stack Overflow See other posts from Stack Overflow or by labilbe
Published on 2008-12-17T03:46:44Z Indexed on 2010/04/19 7:43 UTC
Read the original article Hit count: 294

Filed under:

Hello,

I am using a route like this one:

            routes.MapRoute("Invoice-New-NewCustomer",
                        "Invoice/New/Customer/New/{*name}",
                        new { controller = "Customer", action = "NewInvoice" },
                        new { name = @"[^\.]*" });

There is an action which handles this route:

        public ActionResult NewInvoice(string name)
    {
        AddClientSideValidation();
        CustomerViewData viewData = GetNewViewData();
        viewData.InvoiceId = "0";
        viewData.Customer.Name = name;
        return View("New", viewData);
    }

When I call return RedirectToAction("NewInvoice", "Customer", new {name}); and name is equal to "The C# Guy", the "name" parameter is truncated to "The C".

So my question is : What is the best way to handle this kind of special character with ASP.NET MVC?

Thanks!

© Stack Overflow or respective owner

Related posts about asp.net-mvc