How to use ScriptManager with Razor in MVC 4?

2019-08-24 02:54发布

I used ScriptManager in .aspx page to Maintain URL history in .Net i.e.

on aspx page i put this script after form tag

> <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true"
>         EnableHistory="true">       
>     </asp:ScriptManager>

and in my .js file i put this code

Sys.Application.add_navigate(function (sender, e) {
    navigate(sender, e);
});

 Sys.Application.addHistoryPoint(objOut, null);

Now same thing i want to use in MVC 4 with Razor

I used MicrosoftAjax.js for ScriptManager and .js code is same. but i am getting issue on callback.

let me explain you with example:

suppose Actual URL is
www.websitename.com/cat/30/

anchor tag link on page is 
www.websitename.com/cat/30/?q=10

once callback perform anchor tag link becomes
www.websitename.com/?q=10

I mean after callback "cat/30/" is missing from link.

can anyone tell me what I am doing wrong.

Thanks.

Ashu

1条回答
Animai°情兽
2楼-- · 2019-08-24 03:20

ScriptManager is part of ASP.NET Webforms. It is not available in ASP.NET MVC. They are two completely different frameworks.

There is a port of ScriptManager to ASP.NET MVC which is available here. It might provide what you are looking for.

查看更多
登录 后发表回答