In EPiServers public template they have given me a nice way to redirect the user after a XForm have been submitted by hooking up on the AfterSubmitPostedData event.
public void XForm_ControlSetup(object sender, EventArgs e)
{
var control = (XFormControl)sender;
control.AfterSubmitPostedData += XForm_AfterSubmitPostedData;
}
public void XForm_AfterSubmitPostedData(object sender, SaveFormDataEventArgs e)
{
var control = (XFormControl)sender;
if (control.FormDefinition.PageGuidAfterPost != Guid.Empty)
{
var pageMap = PermanentLinkMapStore.Find(control.FormDefinition.PageGuidAfterPost) as PermanentPageLinkMap;
if (pageMap != null)
{
control.Page.Response.Redirect(pageMap.MappedUrl.ToString());
return;
}
}
}
If XForm_AfterSubmitPostedData is never triggered this is probably because the SMTP settings is wrong in web.config(!!?).
IMOHO this is a bug and a very stupid way to handle this error, episerver should throw an exception!
Anyway… go ahead and download smtp4dev which is a great dummy SMTP server for developers. And then change the SMTP settings in web.config to something like this:
<mailSettings>
<smtp from="noreply@dummy.com" deliveryMethod="Network">
<network host="localhost" port="25" userName="" password="" defaultCredentials="false" />
</smtp>
</mailSettings>
Voila!
2011-12-19
0 Comments