0

Working in a MVC project using C# .Net. I have a top menu where I have links to different views. I'm trying to get my button click to take me to one of my views;

<input type="button" value="About Me" onclick="location.href='<%= @Url.Action("About Me", "AboutMePage") %>'"/>

But I'm hit with this error:

A potentially dangerous Request.Path value was detected from the client (<).

Not sure where I'm going wrong?

Cheers.

cb34r
  • 3
  • 2
  • You are not doing it the MVC way. Your problem is that '<' is being taken literally, it's not being resolved. – Palle Due Apr 15 '20 at 11:47
  • Have a look at this: https://stackoverflow.com/questions/3168577/how-do-i-redirect-a-user-when-a-button-is-clicked – Palle Due Apr 15 '20 at 11:52
  • @PalleDue The only different I see is that they suggest window.location.href and a semi-colon at the end? Tried it and it's the same. – cb34r Apr 15 '20 at 11:57

1 Answers1

0

Try to add a Controller to Post your action.

<input type="submit" value="About Me"/>

After your controller

        [HttpPost]
        public ActionResult Index()
        {

                return RedirectToAction("About Me", "AboutMePage");

        }
MERLIN
  • 61
  • 1
  • 13