Greg Gum
Greg Gum

Reputation: 38139

Why does JScript URL work differently in VS, then when published

I have this which works in Visual Studio. It does not work when Published:

$.ajax({
        url: "Order/EditLineItem",
        data: { id: dataItem.id },
        dataType: 'html',
        success: function (data) {
            $('#content').html(data); // 
        }

This, on the other hand, works when published, but not in Visual Studio:

$.ajax({
        url: "/PropertySearch/Order/EditLineItem",
        data: { id: dataItem.id },
        dataType: 'html',
        success: function (data) {
            $('#content').html(data); // 
        }

The only difference is adding the site name "PropertySearch" at the start of the URL.

Is there some way to write this so that it works in both?

This is the current route:

 routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Order", action = "Start", id = UrlParameter.Optional }
        );

Upvotes: 0

Views: 27

Answers (1)

Greg Gum
Greg Gum

Reputation: 38139

The answer here is to:

  1. Go to Project Property Page.

  2. Web Tab

  3. Find "Virtual Path:" and enter the site name.

Then when you run in VS, you will see the Virtual Path in the Browser address bar appended to the root.

Works for me.

Upvotes: 1

Related Questions