2

When upgrading an ASP.NET 4 (3.5 rendering) WebForms application to MVC 3, how can I get the same JavaScript generated by ScriptManager for a ServiceReference of an ASMX file?

I have an ASMX web service file that is used extensively via the JavaScript ScriptManager generates for it. The existing code needs to continue to work but you can't use ScriptManager in an MVC view. Is there a way to have the JavaScript code automatically generated in ASP.NET MVC?

Here is how I have it in my Default.aspx WebForm page:

<asp:ScriptManager ID="sm" runat="server">
    <Services>
        <asp:ServiceReference Path="/WebService.asmx" />
    </Services>
</asp:ScriptManager>
0

1 Answer 1

3

I had to add MicrosoftAjax.js and WebService.asmx/js to the page.

<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script src="/WebService.asmx/js" type="text/javascript"></script>

Note the trailing /js in /WebService.asmx/js.

Appending /js to the path of the .asmx file gives you the Javascript for your webservice. Likewise, appending /jsdebug gives you the verbose Javascript for debugging purposes.

Sign up to request clarification or add additional context in comments.

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.