本文介绍了ASP.NET MVC 4和ContextDependentView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始的测试版播放,并在那里发现了一点点魔法。当我看 _LoginPartial.cshtml 即建立注册链接线只是说:

I have just started playing with the Beta and discovered a bit of black magic in there. When I look at _LoginPartial.cshtml the line that builds the Register link simply says:

@ Html.ActionLink(注册,注册,帐户,routeValues​​:空,htmlAttributes:新{ID =registerLink,data_dialog_title =注册})

呈现在浏览器上的链接表示, /帐号/注册。然而,在注册视图的形式呈现的行动 /帐号/ JsonRegister 根据 ViewBag.FormAction 值。在哪里这个值设置?我怀疑它的东西做了 ContextDependentView 注册操作返回,但不能完全弄清楚如何或者为什么。

The link rendered on the browser says /Account/Register. However, the form in the Register view renders the action as /Account/JsonRegister based on ViewBag.FormAction value. Where was this value set? I have a suspicion it's something to do with that ContextDependentView returned by the Register action but can't quite figure out how or why.

任何想法吗?

推荐答案

真正神奇的是在AjaxLogin.js文件,该文件修改的链接添加在ContextDependentView使用的内容= 1查询字符串参数来决定是否发送背JSON形式或常规形式。

The real magic is in the AjaxLogin.js file, which modifies the link to add the content=1 querystring parameter that is used in ContextDependentView to decide whether to send back the json form or the regular form.

这一切只是jQuery的东西,大多数人不懒得看。

This is all just jquery stuff that most people don't bother to look at.

这篇关于ASP.NET MVC 4和ContextDependentView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 09:05