Ouma
Ouma

Reputation: 15

Deploy web app to Azure but still showing Microsoft page instead of the webform created

I am attempting to publish a web app (mvc project) from visual studio to azure but I keep getting the blow page enter image description here

I am not sure what to do. I've added WebForm2.aspx in the default document (on azure) and added the below tag in the web.config page but still no luck enter image description here

Any ideas please?

Upvotes: 0

Views: 71

Answers (1)

Purvesh Sangani
Purvesh Sangani

Reputation: 305

You can just use a Response.Redirect from your WebForms code with the right URL which gets routed to your controller in question, I guess in your case, that is:

Response.Redirect("/Home/Index");

Or even better you could make an extension method for HtmlHelper that handles your routing:

public static class ExtensionMethods
    {
        public static MvcHtmlString WebFormActionLink(this HtmlHelper htmlHelper, string linkText, string ruoteName, object routeValues)
        {
            var helper = new UrlHelper(htmlHelper.ViewContext.RequestContext);

            var anchor = new TagBuilder("a");
            anchor.Attributes["href"] = helper.RouteUrl(routeName, routeValues);
            anchor.SetInnerText(linkText);
            return MvcHtmlString.Create(anchor.ToString());
        }
    }

Your Routes:

public static void RegisterRoutes(RouteCollection routes)
{

    routes.MapPageRoute(
          "Webforms-Route", // Route name
          // put your webforms routing here
         );

        routes.MapRoute(
            "MVC-Route", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
            );
    }

You would then just pass in your route to your HtmlHelper and you will get the correct route.

Upvotes: 2

Related Questions