Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Had been trying out the new Umbraco V7.4.2 with the Umbraco Forms V4.2.1 and was wondering what's the best way to redirect the user upon submission of the Umbraco Forms to an uploaded media (Eg pdf file)?
Will it be better to use a Form Workflow (if yes, where should I put the redirect code, will it be in the Execute() method?)
Or is there any Umbraco Event that I can hook into use that detects the Form submission?
If you're using forms then there should be no need to make a redirect after form submission manually unless you're doing something very customized I think?
When you click on the form in the "Forms" section you can click on the "Actions" button in the upper right corner and select the "On submit" button. Here you can create text to be displayed OR choose a page that should be shown when the form has been submitted. I guess it's that option you're looking for? :)
Hope this helps.
Yup saw that. But wanted to redirect to a media file (pdf for download). but the option only allow for content node redirection.
Any other way?
Perhaps you could redirect to a content node that then performs another redirect to a media file?
If you known the URL of the media file and can hardcode it, you can just do that in the CSHTML file for the form (you can create custom CSHTML files for particular forms so that not all forms share the same CSHTML file).
If you need the URL to be dynamic, you can create a custom field type for Umbraco Forms. That field type can include a media picker. You can make it so that it doesn't render on the frontend of the website, so you'd essentially just be using this field type to attach extra data to your form. When the form is submitted, you can query this form for all of its fields to find the media picker custom field that you created to extract the URL of the media item. A simpler alternative would be to just use a hidden field that contains the URL of the media item. You can then redirect to that URL.
Just to supplement my previous post, I thought of a slight variation that may be more optimal.
Rather than redirecting to a content that then performs another redirect to the media file, you could actually just do it in a single redirect.
Essentially, you'd create a custom URL provider that detects a document type of "MediaRedirect" (or whatever you want to call it). If so, you could get the URL of the media item from a media picker property on that content node then return that as the URL to use rather than the URL of the content node.
Assuming Umbraco Forms is getting URL's in the usual way, it ought to redirect directly to the media file rather than the content node.
Cool. Let me try that out. Thanks Nicholas
Hey Nicholas works like a charm. Tested today. All sweet :)
Glad to hear it! By the way, you might want to post some of your code here so that others can benefit from your work :-)
I've got my UrlProvider setup as below with the event's setup :)
Sharing it if in case anyone is looking for the same thing like what Nicholas had recommended.
public class FormDownloadItemUrlProvider : IUrlProvider
public string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
var content = umbracoContext.ContentCache.GetById(id);
if (content != null && content.DocumentTypeAlias == "FormDownloadItem" && content.Parent != null)
var fileNode = content.GetPropertyValue<IPublishedContent>("filePicker");
if (fileNode != null)
// Swapping the existing URL with the File Picker's URL for form redirection
public IEnumerable<string> GetOtherUrls(UmbracoContext umbracoContext, int id, Uri current)
So once you've got your URL provider setup, all you need to is call that from your Umbraco Event as below
public class UmbracoEvents : IApplicationEventHandler
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
//With the url providers we can change node urls.
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
Does anyone have a working implementation of this for v8?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted