mackie1908
mackie1908

Reputation: 475

MVC 4 random value added to URL

For some reason on all of my URLs for my MVC 4 application the app seems to be adding random anchor values such as #.Uhz_BdLbNz4 to the end of my URL and I cannot figure out why. I am sure its something simple but it is driving me nuts and I can't find anything about it online.

Does anyone know what it is and how to get rid of it?

Cheers

Danny

Update: As requested my route config is just the standard one below

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 }
        );
    }
}

an example link:

    <a href="@Url.Action("Sessions", "Training", new { Month=DateTime.Now})">Find a Session >></a>

and finally some example generated HTML:

    <ul class="top-nav cg-22-white">
        <li class="first-item"><a href="/">Home</a></li>
        <li><a href="/news">News</a></li>
        <li><a href="/mercedes/about">About Mercedes</a></li>
        <li><a href="/contactus">Contact Us</a></li>
        <li><a href="/blog">Blog</a></li>
    </ul>

and

<a href="/Training/Sessions?Month=08%2F27%2F2013%2020%3A44%3A44">Find a Session >></a>

Upvotes: 0

Views: 1655

Answers (1)

joargp
joargp

Reputation: 440

<a href="/Training/Sessions?Month=08%2F27%2F2013%2020%3A44%3A44">Find a Session >></a>

The value at the end of the generated url is not random, it's a string representation of DateTime.Now-object you inserted in the annonymous object in the Url.Action-Helper. If you don't what that parameter sent, just remove the annonymous object for the Url.Action

PS: If you have a DateTime parameter on the action called month, this should be binded automatically for you.

Upvotes: 1

Related Questions