I have 2 pages in sitefinity (w/MVC) that have different controllers with identical parameters. One returns a page with search results and all the form elements to conduct that search.
I would like a 'print' button on that first form to send all the form fields to a different page, with a different controller/component with the same parameters.
(I have posted the same question on Sitefinity's forums, but have not yet received a response. I have also been searching for this, but not finding similar results)
In ASP.Net, or Actual MVC, this would work easily.
In MVC I was able to do it like this:
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;
but in Sitefinity's MVC that same code produces this error: (at the correct page)
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
This occurs because the page contains view state, and view state is only decipherable by the page which generated it. The target page is trying to decipher this field, but it can't and is instead throwing an exception.
Immediately before the call to submit(), try searching the DOM for the hidden form field named "__VIEWSTATE" and set its value to the empty string (""). This will cause the destination page not to try to load view state.
Related
We are setting a Key for the Storage Account and then using to access the contents as below;
var storageCredentials = new StorageCredentials(mediaStorageAccountName, base64EncodedKey);
var storageAccount = new CloudStorageAccount(storageCredentials, true);
var connString = storageAccount.ToString(true);
Then, using the same "storageAccount" to create the Blob Client;
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
And to get the Container;
var container = blobClient.GetContainerReference(ContainerName);
"storageAccount" Credential properties are "IsSAS" FALSE, "IsSharedKey" TRUE, "IsToken" FALSE and "KeyName" is NULL.
But, when Blob is being accessed with OpenReadAsync, its failing with following exception;
The remote server returned an error: (403) Forbidden.,The remote server returned an error: (403) Forbidden. Line number: Microsoft.WindowsAzure.Storage Trace: at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.EndExists(IAsyncResult asyncResult)
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass2`1.b__0(IAsyncResult ar)
It is basically getting all the references to Container/Blobs etc correctly (gives correct name), but when its tried to read/download/upload those, it fails.
Also, instead of using the "storageAccount" reference directly, even if it is secured with following, it gives same exception;
CloudStorageAccount storageAccount = new CloudStorageAccount(
new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(storageAccountName, base64EncodedKey), true);
What is wrong here and how to fix this?
Why is KeyName NULL? Is that causing this issue?
The 403 forbidden exception often caused by a wrong access key is used.
As you are using Authorize with Shared Key, all authorized requests must include the Coordinated Universal Time (UTC) timestamp for the request. You can specify the timestamp either in the x-ms-date header, or in the standard HTTP/HTTPS Date header.
The storage services ensure that a request is no older than 15 minutes by the time it reaches the service. This guards against certain security attacks, including replay attacks. When this check fails, the server returns response code 403 (Forbidden).
So, review your server datatime.
Any help appreciated.
The error message reads:
System.UriFormatException: Invalid URI: The format of the URI could not be determined. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at System.Uri..ctor(String uriString) at System.Web.Services.Protocols.WebClientProtocol.set_Url(String value) at WebApplication1.Chase.pconWSService.set_Url(String Value) in \Visual Studio 2008\Projects\WebApplication1\WebApplication1\Web References\Chase\Reference.vb:line 102 at WebApplication1.Chase.pconWSService..ctor() in \Visual Studio 2008\Projects\WebApplication1\WebApplication1\Web References\Chase\Reference.vb:line 83
But is this referring to the web reference (wsdl)? And why 2 different locations?
The wsdl was given to me by the vendor, anyway here is my code, it's short:
Protected Sub transfer()
Try
Dim objXMLHTTP As New MSXML2.ServerXMLHTTP60()
Dim service As New Chase.pconWSService ' The error is thrown here
The problem was my web config was not pointed at the actual web service (host) but at my local machine. Once I repointed it the thing worked.
I am trying to chain 2 adfs instances together. We have an application protected by one ADFS and users that are in another AD that also uses ADFS to protect applications. Now I am trying to give access to an application protected by one ADFS to the users in the Other ADFS.
In the ADFS that has the users in AD, I have set up a new RelyingParty that is the other ADFS instance.
In the ADFS that protects the application I have set up a Claims Provider trust, I did this by pointing at the metadata of the ADFS instance that has the users in Active Directory. This seems to be working.
Now when I try to access my protected application, I get certificate errors for the SSO certs, I click through those then it bounces me to the RP ADFS and a page displays giving me the choice of authentication either AD or my ID ADFS instance. I choose the ID ADFS that I have just set up, click continue and it bounces me to the log in page. After logging in it bounces me back to the RP ADFS server and then I get an error, with a reference number. When I look up the reference number in the event log I see either 2 or 3 errors.
the first is about a revocation list
An error occurred during an attempt to build the certificate chain for the claims provider trust 'http://dev-sso.xxxxxxx.com/adfs/services/trust' certificate identified by thumbprint '54xxxxxxxxxxxxxxxxxxxxxxE28C9A57481'. Possible causes are that the certificate has been revoked, the certificate chain could not be verified as specified by the claims provider trust's signing certificate revocation settings or certificate is not within its validity period.
The second is
The Federation Service encountered an error while processing the WS-Trust request.
Request type: http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue
Additional Data
Exception details:
Microsoft.IdentityModel.Protocols.XmlSignature.SignatureVerificationFailedException: ID4037: The key needed to verify the signature could not be resolved from the following security key identifier 'SecurityKeyIdentifier
(
IsReadOnly = False,
Count = 1,
Clause[0] = Microsoft.IdentityServer.Tokens.MSISSecurityKeyIdentifierClause
)
'. Ensure that the SecurityTokenResolver is populated with the required key.
at Microsoft.IdentityModel.Protocols.XmlSignature.EnvelopedSignatureReader.ResolveSigningCredentials()
at Microsoft.IdentityModel.Protocols.XmlSignature.EnvelopedSignatureReader.OnEndOfRootElement()
at Microsoft.IdentityModel.Protocols.XmlSignature.EnvelopedSignatureReader.Read()
at System.Xml.XmlReader.ReadEndElement()
at Microsoft.IdentityModel.Tokens.Saml11.Saml11SecurityTokenHandler.ReadAssertion(XmlReader reader)
at Microsoft.IdentityModel.Tokens.Saml11.Saml11SecurityTokenHandler.ReadToken(XmlReader reader)
at Microsoft.IdentityModel.Tokens.SecurityTokenHandlerCollection.ReadToken(XmlReader reader)
at Microsoft.IdentityModel.Tokens.SecurityTokenElement.ReadSecurityToken(XmlElement securityTokenXml, SecurityTokenHandlerCollection securityTokenHandlers)
at Microsoft.IdentityModel.Tokens.SecurityTokenElement.GetSecurityToken()
at Microsoft.IdentityServer.Service.SecurityTokenService.MSISSecurityTokenService.GetOnBehalfOfPrincipal(RequestSecurityToken request, IClaimsPrincipal callerPrincipal)
at Microsoft.IdentityServer.Service.SecurityTokenService.MSISSecurityTokenService.BeginGetScope(IClaimsPrincipal principal, RequestSecurityToken request, AsyncCallback callback, Object state)
at Microsoft.IdentityModel.SecurityTokenService.SecurityTokenService.BeginIssue(IClaimsPrincipal principal, RequestSecurityToken request, AsyncCallback callback, Object state)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.DispatchRequestAsyncResult..ctor(DispatchContext dispatchContext, AsyncCallback asyncCallback, Object asyncState)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.BeginDispatchRequest(DispatchContext dispatchContext, AsyncCallback asyncCallback, Object asyncState)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.ProcessCoreAsyncResult..ctor(WSTrustServiceContract contract, DispatchContext dispatchContext, MessageVersion messageVersion, WSTrustResponseSerializer responseSerializer, WSTrustSerializationContext serializationContext, AsyncCallback asyncCallback, Object asyncState)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.BeginProcessCore(Message requestMessage, WSTrustRequestSerializer requestSerializer, WSTrustResponseSerializer responseSerializer, String requestAction, String responseAction, String trustNamespace, AsyncCallback callback, Object state)
Microsoft.IdentityModel.Protocols.XmlSignature.SignatureVerificationFailedException: ID4037: The key needed to verify the signature could not be resolved from the following security key identifier 'SecurityKeyIdentifier
Microsoft.IdentityModel.Protocols.XmlSignature.SignatureVerificationFailedException: ID4037: The key needed to verify the signature could not be resolved from the following security key identifier 'SecurityKeyIdentifier
I decided to disable the revocation list check. I think the issue is a proxy or firewall that sits in the way, in production we will have real certificates and so I think this will be less of a problem.
So not really the answer but enough to move on.
I am consuming a WCF in a classLibrary by adding a web reference of the WCF service.
All the classes of service are showing, their is no build error.
But when calling the method of service, getting the below mentioned error:-
And I am passing a object in the method which contains the xml.
But when I am making a proxy class by using svcutil.exe ,then call the method of service with the same object having same xml no error is coming, it is working fine.
_**It means that in classLibrary we can consume a WCF service only by creating a proxy not by adding the web reference of the WCF service.
Is the above statement is correct or not?
If not then please provide a solution for it.**_
**Error:
System.InvalidOperationException: There is an error in XML document (1, 528). ---> System.InvalidOperationException: Instance validation error: '' is not a valid value for PropertySubType.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderHotelFlow.Read29_PropertySubType(String s)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderHotelFlow.Read30_Hotel(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderHotelFlow.Read31_SearchResult(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderHotelFlow.Read100_SearchHotelsResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer8.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at ClassLibTestTouricoWCFinCsharp.com.touricoholidays.demo2.HotelFlow.SearchHotels(SearchRequest request) in C:\Documents and Settings\Prakash.singh\My Documents\Visual Studio 2005\Projects\ClassLibTestTouricoWCFinCsharp\ClassLibTestTouricoWCFinCsharp\Web References\com.touricoholidays.demo2\Reference.cs:line 132
at ClassLibTestTouricoWCFinCsharp.Class1.test() in C:\Documents and Settings\Prakash.singh\My Documents\Visual Studio 2005\Projects\ClassLibTestTouricoWCFinCsharp\ClassLibTestTouricoWCFinCsharp\Class1.cs:line 78**
You're basically seeing the difference between a Service Reference and a Web Reference. What it sounds like is that the WCF service you are consuming is not compatible with adding a web reference, and you should instead use the service reference.
Having said that, it's much cleaner to not use either, and instead use a ChannelFactory or create your own proxy by deriving from ClientBase. Here is an example of using a ChannelFactory.
ChannelFactory<IContract> factory = new ChannelFactory<IContract>("BindingConfigName");
IContract channel = factory.CreateChannel();
channel.YourOperation();
((ICommunicationObject)channel).Close();
I experience a weird behavior when accessing my web services into a web browser and it leads to an exception while generating.
Here is my scenario:
Access web page: http://localhost:10100/WCFService1.svc?wsdl
Access web page: http://localhost:10100/WCFService2.svc?wsdl
The problem is that the output of WCFService2.svc WSDL contains all the definition of WCFService1 merged with WCFService2.
Furthermore, when I access another WSDL which contains a method having the same name of previously generated WSDL, I get this exception (surely because my WSDL are being merged together).
I also notice the name of the contract is kind of weird having the ":" before the service name: http://MyCompany.ca/:IWCFService3
Someone have a clue what is going on with the "WSDL export extension"?
An ExceptionDetail, likely created by
IncludeExceptionDetailInFaults=true,
whose value is:
System.InvalidOperationException: An exception was thrown in a call to a
WSDL export extension:
System.ServiceModel.Description.DataContractSerializerOperationBehavior
contract: http://MyCompany.ca/:IWCFService3
----> System.InvalidOperationException: The
MyCompany.IWCFService3.Import
operation references a message element
[http://MyCompany.ca/:Import] that has
already been exported from the
MyCompany.IWCFService2.Import
operation. You can change the name of
one of the operations by changing the
method name or using the Name property
of OperationContractAttribute.
Alternatively, you can control the
element name in greater detail using
the MessageContract programming model.
at System.ServiceModel.Description.MessageContractExporter.AddElementToSchema(XmlSchemaElement
element, String elementNs,
XmlSchemaSet schemaSet)
at System.ServiceModel.Description.MessageContractExporter.ExportWrappedPart(Message
message, String elementName, String
elementNs, XmlSchemaSet schemaSet,
Boolean skipSchemaExport)
at System.ServiceModel.Description.DataContractSerializerMessageContractExporter.ExportBody(Int32
messageIndex, Object state)
at System.ServiceModel.Description.MessageContractExporter.ExportMessage(Int32
messageIndex, Object state)
at System.ServiceModel.Description.MessageContractExporter.ExportMessageContract()
at System.ServiceModel.Description.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IWsdlExportExtension.ExportContract(WsdlExporter
exporter,
WsdlContractConversionContext
contractContext)
at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext
contractContext, IWsdlExportExtension
extension)
I found my problem: We have a huge set of Web Services and we were having a single instance of System.ServiceModel.Description.ServiceMetadataBehavior that we were sharing among all the services. Making a new instance of ServiceMetadataBehavior for each service fixed the issue.