1

I try to do left-side bar but all time i get error "[HttpException (0x80004005):Detected a potentially dangerous value Request.Path coming from the customer". What is wrong with that?

<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="~/Content/bootstrap.css" rel="stylesheet" /> <link href="~/Content/bootstrap-theme.css" rel="stylesheet" /> <link type="text/css" rel="stylesheet" href="~/Content/bootstrap.css" /> <title>@ViewBag.Title</title> </head> <body> <div class="navbar navbar-inverse" role="navigation"> <a class="navbar-brand" href="@ Url.Action("List","Person")">Aplikacja</a> </div> <div class="row"> <div class="col-xs-2"> <ul class="nav nav-pills nav-stacked span3"> <li><a href="@Html.ActionLink("Przyklad1", "Navigator")">Przyklad </a></li> </ul> </div> <div class="col-xs-8"> @RenderBody() </div> </div> </body> </html> 
4
  • See the "space" between @ and Url... remove it. It should be @Url.Action(...) Commented Oct 21, 2016 at 12:39
  • @ Url.Action is working, but @Html.ActionLink("Przyklad1"....) is not Commented Oct 21, 2016 at 12:46
  • How about copying the url from the generated html so we can have a look at what the browser is seeing. Commented Oct 21, 2016 at 12:48
  • 1
    Use @Html.ActionLink("Przyklad1", "Navigator") Not <a href="@Html.ActionLink... You dont need to put Actionlink in an anchor tag. Commented Oct 21, 2016 at 12:48

1 Answer 1

1

@Html.ActionLink generates the markup for an anchor tag. You do not want to set that as the href value of another anchor tag.

When razor executes your current code, It will try to generate markup like below

<a href="<a href='/Navigator'>Przyklad1</a>">Przyklad</a> 

Which is clearly invalid!

Solution : Either simply use Html.ActionLink alone,

<li>@Html.ActionLink("Przyklad","Navigator", "YourControllerName")</li> 

Or

use use Url.Action to set the href value of an anchor tag.

<li><a href="@Url.Action("Navigator","YourControllerName")">Przyklad </a></li> 
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.