Sitefinity - 如何使用类似组件发布到其他页面

时间:2014-01-27 22:24:01

标签: sitefinity

我在sitefinity(w / MVC)中有2个页面,它们具有相同参数的不同控制器。一个页面返回一个包含搜索结果和所有表单元素的页面以进行搜索。

我希望第一个表单上的“打印”按钮将所有表单字段发送到不同的页面,其中不同的控制器/组件具有相同的参数。

(我在Sitefinity的论坛上发布了相同的问题,但尚未收到回复。我也一直在搜索,但没有找到类似的结果)

在ASP.Net或Actual MVC中,这很容易 在MVC中,我能够这样做:

            var d = document;
            var f = d.forms[0];
            window.open('', 'B2BDownload', 'width=900,height=800,resizable,scrollbars;');
            var pt = f.target;
            var pm = f.action;
            f.action = '/UtilityPages/DownloadInvoices';
            f.target = 'B2BDownload';
            f.submit();
            f.action = pm;
            f.target = pt;

但在Sitefinity的MVC中,相同的代码会产生此错误:(在正确的页面上)

Server Error in '/' Application.

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

Source Error: 


[No relevant source lines]

Source File: c:\Users\dsagmi\AppData\Local\Temp\Temporary ASP.NET Files\root\e2f026a5\8dd189ac\App_Web_15de2cba-1969-6a7f-bafc-ff00004b1c1a_20t98b8c6261_dealerportal_en.aspx.d63928b6.zmrfaltr.0.cs    Line: 0 

Stack Trace: 


[ViewStateException: Invalid viewstate. 
Client IP: ::1
Port: 41710
Referer: http://localhost:60876/history/order-invoice-history
Path: /UtilityPages/PrintInvoices
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36
ViewState: /wEPDwULLTE1NDc5NTk3MzZkZEkHl7CSK6SqsTcfmGWe//o1dcqh]

[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +198
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +432
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Deserialize(String serializedState, Purpose purpose) +8
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +40
System.Web.UI.HiddenFieldPageStatePersister.Load() +248
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +88
System.Web.UI.Page.LoadAllState() +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
System.Web.UI.Page.ProcessRequest() +72
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +58
    ASP.sfpageservice_15de2cba_1969_6a7f_bafc_ff00004b1c1a_20t98b8c6261_dealerportal_en_aspx.ProcessRequest(HttpContext context) in c:\Users\dsagmi\AppData\Local\Temp\Temporary ASP.NET Files\root\e2f026a5\8dd189ac\App_Web_15de2cba-1969-6a7f-bafc-ff00004b1c1a_20t98b8c6261_dealerportal_en.aspx.d63928b6.zmrfaltr.0.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET      Version:4.0.30319.18408

1 个答案:

答案 0 :(得分:3)

这是因为页面包含视图状态,并且视图状态只能由生成它的页面进行解密。目标页面正在尝试解密此字段,但它不能并且正在抛出异常。

在调用submit()之前,尝试在DOM中搜索名为“__VIEWSTATE”的隐藏表单字段,并将其值设置为空字符串(“”)。这将导致目标页面不尝试加载视图状态。