Sitefinity CMS:Html.BeginFormSitefinity与外部网址是什么? [英] Sitefinity CMS: Html.BeginFormSitefinity with external URL?

查看:286
本文介绍了Sitefinity CMS:Html.BeginFormSitefinity与外部网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能帮助我在这里 - 我试图建立一个基本的MVC窗口小部件Sitefinity将发布到外部URL登录用户在那里。现在的问题是,如果我使用普通的HTML做到这一点,小部件只会在纯MVC模式的感谢与表单方式的WebForms交易的工作。

I'm hoping someone can help me here - I'm trying to set up a basic MVC widget for Sitefinity that will POST to an external URL to log the user in there. The problem is if I use regular HTML to do this, the widget will only work in pure MVC mode thanks to the way WebForms deals with forms.

我GOOGLE了一下周围,发现人解释说,与常规的BeginForm,你可以指定一个外部动作URL正是如此:

I googled around a bit and found people explaining that with the regular "BeginForm" you can specify an external action URL thusly:

Html.BeginForm(null, null, FormMethod.Post, new { @action="EXTERNAL_URL" })

这将产生以下开头的表单标签:

Which produces the following opening form tag:

<form action="EXTERNAL_URL" method="post">

这个作品非常漂亮,但还是输一个普通的HTML表单不与Sitefinity工作,所以Sitefinity有它自己的方法来生产,将在混合模式Html.BeginFormSitefinity的工作形式。此方法具有所有相同的覆盖,但以同样的方式不表现 - 当我试图用此code:

This works very nicely, but still outputs a regular HTML form which doesn't work with Sitefinity, so Sitefinity has it's own method to produce forms that will work in Hybrid mode "Html.BeginFormSitefinity". This method has all of the same overrides but doesn't behave in quite the same way - when I attempt to use this code:

Html.BeginFormSitefinity(null, null, FormMethod.Post, new { @action="EXTERNAL_URL" })

这将产生以下开头的表单标签:

This produces the following opening form tag:

<form action="/TestProject/TestPage/Index" method="POST" name="defaultForm" action="EXTERNAL_URL">

正如你所看到的,它在弹出而第二个动作属性不是覆盖action属性作为默认的MVC方法的行为观察。

As you can see, it's popping a second action attribute in rather than overriding the action attribute as seen in the default MVC method's behaviour.

我希望有人有更好的理解Sitefinity如何工作也许可以在这里提供一些建议?

I'm hoping that someone with a better understanding of how Sitefinity works might be able to provide some advice here?

推荐答案

综观HybridForm的来源,它不能被修改,因此将采取动作 htmlAttribute考虑: http://pastebin.com/5dfQdzs8

Looking at the sources of the HybridForm, it cannot be modified so it will take action htmlAttribute into account: http://pastebin.com/5dfQdzs8

所以,你可以在此基础上code创建自己的形式。
你需要的HTML帮助:

So you may create your own form based on this code. You'll need html helper:

public static MyHybridForm BeginFormSitefinity(this HtmlHelper htmlHelper, string actionName, string formName, FormMethod method, IDictionary<string, object> htmlAttributes)
{
  return new MyHybridForm(htmlHelper.ViewContext, actionName, formName, method, (object) htmlAttributes);
}

和覆盖 GenerateActionUrl() MyHybridForm 用行动htmlAttribute考虑。

and override GenerateActionUrl() in your MyHybridForm by using action htmlAttribute into account.

这篇关于Sitefinity CMS:Html.BeginFormSitefinity与外部网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆