|
I have a MVC 4 application (with jQuery Mobile) working and I'm trying to build some Administrative pages which will be implemented as WebForms. The problem I am having is that I can't seem to get the Html.ActionLink to send the user to those admin pages.
The admin pages reside in a /AdminUtils folder off the root of the application.
Based on some searching, I've added the following to my Global.asax.vb
Sub Application_Start()
AreaRegistration.RegisterAllAreas()
WebApiConfig.Register(GlobalConfiguration.Configuration)
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters)
RouteConfig.RegisterRoutes(RouteTable.Routes)
BundleConfig.RegisterBundles(BundleTable.Bundles)
End Sub
Sub RegisterRoutes(Routes As RouteCollection)
Routes.IgnoreRoute("AdminUtils/{*pathInfo}")
Routes.MapPageRoute("ReportRoute", "AdminUtils/{someparam}", "~/AdminUtils/{someparam}.aspx")
End Sub
In my Index.vbhtml page I have the following:
@Html.ActionLink("Admin Link", "AdminUtils", New With {.Page = "WebForm1.aspx"})
However, if I hover over the link, it indicates that it wants to route to:
http://localhost:63163/Home/AdminUtils?Page=WebForm1.aspx
If I use a standard hyperlink,
<a href="~/AdminUtils/WebForm1.aspx" title="Form 1">Webform1 Here </a>
the browser is directed to the page and WebForm1.aspx displays as normal.
I'm thinking it has something to do with the Routing, but I just don't know what to do.
Thank you in advance for you help.
David
|
|
|
|
|
I've not done this work directly, but the actionlink feels wrong, as it is accessing a separate, non-MVC app. I'd stick with the plain hyperlink when referring out.
David Mujica wrote: outes.MapPageRoute("ReportRoute", "AdminUtils/{someparam}", "~/AdminUtils/{someparam}.aspx")
Again this feels wrong: you are producing a route map to an external, non-MVC application. It also contradicts the ignore route (which I think is right).
Again you have to mod this all through my inexperience at having embedded non-MVC apps......
|
|
|
|
|
As Keith said, use the href.
Spent some time working on this in an app myself. And after some digging, it seems ActionLink is for routing to internal links within your MVC application.
You can create an actionlink that uses a controller to redirect the user, but that seems like a lot of work to get a simple action done.
public ActionResult MyController(){
return Redirect("http//www.mysite.com");
}
|
|
|
|
|
With MVC, the Html.ActionLink() does not link to a view. It creates a link to a controller action.
If it's just a static link I would just put it as part of the html.
modified 20-Oct-19 21:02pm.
|
|
|
|
|
just wanted to let everyone who responded that I appreciate your help.
After thinking about it for a while, I think I need to use a plain old, hyperlink. Yep.
Thanks again.
|
|
|
|