0

$(document).ready(function () {
    getDefaultPDF();
    loadPDF();   
});

function loadPDF() {
    $('#reportsDiv').load("/Review/DisplayPdfPartial");
}

Our site is hosted under the Default website, within a folder. So the url should be http://servername/foldername/Review/DisplayPdfPartial

but the following code tries to fetch http://servername/Review/DisplayPdfPartial - doesn't add the foldername and fails obviously.

This doesn't happen on local, only when deployed under default website.

What am I missing?

2 Answers 2

2

As you have mentioned you are using Asp.Net MVC then in that case instead of specifying url's this way, a more efficient way is to use @Url.Action() helper method as shown :-

$(document).ready(function () {
    getDefaultPDF();
    loadPDF();   
});

function loadPDF() {
    //$('#reportsDiv').load("/Review/DisplayPdfPartial");
    $('#reportsDiv').load('@Url.Action("DisplayPdfPartial","Review")');
}
Sign up to request clarification or add additional context in comments.

Comments

1

You can use ResolveClientUrl

A fully qualified URL to the specified resource suitable for use on the browser.

Use the ResolveClientUrl method to return a URL string suitable for use by the client to access resources on the Web server, such as image files, links to additional pages, and so on

.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.