简体   繁体   中英

Clicking on link removes the application name from URL, and moves back

I have a Website www.xyz.com hosted on IIS. I have created few child applications within same website.

So, my url becomes www.xyz.com/app1 , now on aap1 home page I have below link, which opens the page on same app1

<a href="Masters/Index">Index</a>

But when I click on the link, It removes application name (ie, app1 ) from URL and browse like below

www.xyz.com/Masters/Index and I end up with resource not found error.

Whereas it should be www.xyz.com/app1/Masters/Index

I tried link with ../ , / , ./ prefix for link but none of them seems to work. I'm a missing something?

Please help.

From within your app1 use an Html.ActionLink helper instead fo the hardcoded link:

@Html.ActionLink("Index", "Masters", "Index")

This should keep the existing routing of the current web application.

LinkExtensions.ActionLink Method (HtmlHelper, String, String, String)

You can also use @Url.Action instead if you prefer to just update the url within your mark-up:

<a href="@Url.Action("Masters", "Index")">Index</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM