WFFM form submitting multiple times - asp.net

When i submit my WFFM forms i can see by two calls going from network,
On my QA environment its working fine but in my PROD its failed.
Please let me know , possible case for this issue
My exception log below
6840 06:57:02 ERROR The anti-forgery cookie token and form field token
do not match. Exception: System.Web.Mvc.HttpAntiForgeryException
Message: The anti-forgery cookie token and form field token do not
match. Source: System.Web.WebPages at
System.Web.Helpers.AntiXsrf.TokenValidator.ValidateTokens(HttpContextBase
httpContext, IIdentity identity, AntiForgeryToken sessionToken,
AntiForgeryToken fieldToken) at
System.Web.Helpers.AntiXsrf.AntiForgeryWorker.Validate(HttpContextBase
httpContext, String cookieToken, String formToken) at
Sitecore.Forms.Mvc.Controllers.Filters.WffmValidateAntiForgeryTokenAttribute.OnAuthorization(AuthorizationContext
filterContext) at
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext
controllerContext, IList`1 filters, ActionDescriptor actionDescriptor)
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__19(AsyncCallback
asyncCallback, Object asyncState)
6840 06:57:02 WARN [WFFM] CurrentSession is not initialized 6840
06:57:02 WARN Web Forms for Marketers: an exception 'The anti-forgery
cookie token and form field token do not match.' has occured while
trying to execute an action ''. 9292 06:57:04 ERROR There was an
attempt to do multiple submits within a time interval, specified in
the "WFM.LimitMultipleSubmits.IntervalInSeconds" setting! Exception:
System.Security.SecurityException Message: There was an attempt to do
multiple submits within a time interval, specified in the
"WFM.LimitMultipleSubmits.IntervalInSeconds" setting! Source:
Sitecore.Forms.Mvc at
Sitecore.Forms.Mvc.Controllers.Filters.WffmLimitMultipleSubmitsAttribute.OnAuthorization(AuthorizationContext
filterContext) at
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext
controllerContext, IList`1 filters, ActionDescriptor actionDescriptor)
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__19(AsyncCallback
asyncCallback, Object asyncState)
9292 06:57:04 WARN [WFFM] CurrentSession is not initialized 9292
06:57:04 WARN Web Forms for Marketers: an exception 'There was an
attempt to do multiple submits within a time interval, specified in
the "WFM.LimitMultipleSubmits.IntervalInSeconds" setting!' has occured
while trying to execute an action ''. ManagedPoolThread #7 06:57:42
INFO Health.PrivateBytes: 905,527,296

Finally issue solved by removed caching on WFFM forms at component level as well as in site definition too.
(But now seeking how do i cache a page alone without caching WFFM forms)

Related

No http handler was found for request type 'GET' in dotnetnuke

Dnn data base and files of dotnetnuke moved to new host but when starting it show error:
The page cannot be displayed because an internal server error has occurred.
i have checked log file of dnn in \Portals\_default\Logs it shows error :
2016-10-16 19:09:25,763 [WIN-MA182KN2LA7][Thread:7][ERROR] DotNetNuke.Entities.Urls.UrlRewriterUtils - System.Web.HttpException (0x80004005): Error executing child request for ~/Default.aspx. ---> System.Web.HttpException (0x80004005): No http handler was found for request type 'GET'
at System.Web.HttpApplication.MapIntegratedHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig, Boolean convertNativeStaticFileModule)
at System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm)
at System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at DotNetNuke.Entities.Urls.AdvancedUrlRewriter.Handle404OrException(FriendlyUrlSettings settings, HttpContext context, Exception ex, UrlAction result, Boolean transfer, Boolean showDebug)
at DotNetNuke.Entities.Urls.AdvancedUrlRewriter.ProcessRequest(HttpContext context, Uri requestUri, Boolean useFriendlyUrls, UrlAction result, FriendlyUrlSettings settings, Boolean allowSettingsChange, Guid parentTraceId)
i have checked url rewitemodule in iis . it has been installed . Domain name is correct to
Handling *.aspx is not defined in iis. go into
IIS manager --> Default Website --> handler Mapping
Check if you have a mapping for aspx... ideally you should see 2 mappings for .aspx...
you can also use the command line to get the info by the following:
C:\Windows\System32\inetsrv>appcmd list config "Default Web Site" -section:handlers >"give output txt file name"

Getting Error Using Microsoft.AspNet.Membership.OpenAuth

I am getting an error using the RegisterExternalLogin control from the Visual Studio templates. After choosing login from Twitter, Twitter seems to process the login ok and then tries to load the response page and then the error occurs.
The error seems to be related to EntityFrameworks after the login method being called from the Microsoft.Aspnet.Membership.OpenAuth dll but that's about all I know.
Does anybody know how to resolve this?
Here is the error message:
[MissingMethodException: Method not found:
'System.Data.Objects.ObjectContext
System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'.]
Microsoft.AspNet.Membership.OpenAuth.EFOpenAuthMembershipDatabase.EnsureDatabaseCreated(DbContext
db) +0
Microsoft.AspNet.Membership.OpenAuth.EFOpenAuthMembershipDatabase.GetMembershipUserName(String
providerName, String providerUserId, Boolean updateLastUsed) +221
Microsoft.AspNet.Membership.OpenAuth.OpenAuthManager.Login(HttpContextBase
context, String providerName, String providerUserId, Boolean
createPersistentCookie) +128
Microsoft.AspNet.Membership.OpenAuth.OpenAuth.Login(String
providerName, String providerUserId, Boolean createPersistentCookie)
+198 FinModelControls.Account.RegisterExternalLogin.ProcessProviderResult()
+594
Having similar exception, submitted a Conect bug.
https://connect.microsoft.com/VisualStudio/feedback/details/811035/microsoft-aspnet-membership-openauth-is-not-compatible-with-entity-framework-6
Solution: Make sure you're using latest v 2.0.0 Microsoft.AspNet.Membership.OpenAuth package, not 1.0.1.

Invalid length for a Base-64 char array

I use asp.net + MVC1.0 and in a web-page I have several forms, within each forms I have called the following function AntiForgeryToken() to generate a hidden value, and in Controller function I have a validate attribute.
When I use JMeter and capture the token using regular expression then post the token with my form to server, I found it throw such a exception:
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.FormatException: Invalid length for a Base-64 char array.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082
[FormatException]: Invalid length for a Base-64 char array.
at System.Convert.FromBase64String(String s)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState)
at System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String serializedToken)
[HttpAntiForgeryException]: A required anti-forgery token was not supplied or was invalid.
at System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String serializedToken)
at System.Web.Mvc.ValidateAntiForgeryTokenAttribute.OnAuthorization(AuthorizationContext filterContext)
at System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)
at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments.
And I am sure the the captured token is exactly same as what we generated, why this exception happened?
Just solved, because I didn't encode the token before post to server .

Send Data Using the WebRequest Class to DotNetOpenAuth website

I am trying to send data to DotNetOpenAuth website as described here http://msdn.microsoft.com/en-us/library/debx8sh9.aspx
Sender receive (500) Internal Server Error. The same code for blank website without DotNetOpenAuth works fine. Should I tweak something?
Here is an exception:
System.ArgumentNullException was unhandled by user code
Message="Value cannot be null.\r\nParameter name: key"
Source="mscorlib"
ParamName="key"
StackTrace:
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at DotNetOpenAuth.OAuth.ChannelElements.OAuthChannel.ReadFromRequestCore(HttpRequestInfo request) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\OAuth\ChannelElements\OAuthChannel.cs:line 145
at DotNetOpenAuth.Messaging.Channel.ReadFromRequest(HttpRequestInfo httpRequest) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\Messaging\Channel.cs:line 372
at DotNetOpenAuth.OAuth.ServiceProvider.ReadRequest(HttpRequestInfo request) in c:\BuildAgent\work\7ab20c0d948e028f\src\DotNetOpenAuth\OAuth\ServiceProvider.cs:line 222
Exception occurs on last line of the code:
private void context_AuthenticateRequest(object sender, EventArgs e)
{
// Don't read OAuth messages directed at the OAuth controller or else we'll fail nonce checks.
if (this.IsOAuthControllerRequest())
{
return;
}
if (HttpContext.Current.Request.HttpMethod != "HEAD")
{ // workaround: avoid involving OAuth for HEAD requests.
IDirectedProtocolMessage incomingMessage = OAuthServiceProvider.ServiceProvider.ReadRequest(new HttpRequestInfo(this.application.Context.Request));
If you're sending the POST request with a Content-Type of application/x-www-form-urlencoded, but the POST entity contains something other than the normal key1=value1&key2=value2 format, that might explain it. It looks like DotNetOpenAuth can't handle a POST entity that claims to be name=value pairs but only has a value without a key in front of it. Arguably that's a bug in DotNetOpenAuth since normally that's just considered a value of a null key.
If you're not sending key=value pairs at all, I suggest you drop or change the Content-Type header so that you're not claiming to be sending key=value pairs. If you are sending them, but intentionally sending a null key, then hang on while the bug gets fixed.

How to redirect to login page from a web service in an AJAX call?

I am using jQuery to call web service (*.asmx) methods. The web service uses FormsAuthentication to determine whether the calling user is authenticated. I am unable to return a redirect status code from the web method, e.g.
[WebMethod(EnableSession=true)]
public Dictionary<string, object> GetArchivedFiles(int pageSize, int page)
{
if(HttpContext.Current.User.Identity.IsAuthenticated && Session["UserId"] != null)
// Do some computing and return a Dictionary.
// Method will fall through here if the user is not authenticated.
HttpContext.Current.Response.StatusCode = (int) HttpStatusCode.Unauthorized;
return null;
}
The redirect does not work, I always get 500 Internal Server Error when doing this. I tried different codes. What would be the recommended way to go here? I need to read the redirect information from JavaScript and load the new page (or maybe display a login control AJAX way).
I actually get a JSON object back, which looks like this:
{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"
}
I tried running the debugger, but it doesn't show that any methods are entered. As you can see the StackTrace is null...
When invoked in Fiddler as a standard POST request (not XMLHttpRequest) it returns an exception actually:
HTTP/1.1 500 Internal Server Error
Server: ASP.NET Development Server/9.0.0.0
Date: Wed, 04 Mar 2009 14:46:02 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 1739
Connection: Close
System.NotSupportedException: The type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.
at System.Xml.Serialization.TypeScope.GetDefaultIndexer(Type type, String memberInfo)
at System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, MemberInfo memberInfo, Boolean directReference)
at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
at System.Xml.Serialization.ModelScope.GetTypeModel(Type type, Boolean directReference)
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root, String defaultNamespace)
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root)
at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
You should not redirect from the Web service. It should return a value to indicate whether or not you should redirect (This could be a separate Authenticate method that returns a string, if it's null, it means it's authenticated, if it isn't it'll contain the redirection URL) Then in javascript, you could check the return value and redirect appropriately by setting the window.location property.
By the way, access to the Web service should not require authentication.
I don't have experience specifically with asp.net but in general I like to use an ajaxResponse object that has properties such as "success", "content", "errortype". A login required response in this case would have a success of "false" and errortype "login", or whatever you choose. The javascript code then decides how to handle the returned object based on these properties, showing the user a login form or redirecting to a new page.
What I did was to get rid of the status code at all and just return null. A method returns an empty list if there are no files, with a total page count of 0. But if the user is not authenticated, it returns null, in such case I use window.location to redirect the browser to the login page.
Throw an exception in the webservice. Catch this in the caller and redirect as necessary.
In fact, if your post to the webservices (ajax or not) contains a "Content-Type" header with value "application/json; charset=utf-8", then the ASMX stack will send you back a json formated string with an exception of the supposed redirect that usually you expect including status code 401 (unauthorized), but, if you don't send any content type header, you well get a browser redirection to the login page as response with status code OK and using ajax, you will get the login page html as response.
Hope that this help on clarifying.
Regards

Resources