private static string GetUrlOptionsQueryString(FileUrlOptions options) { if ((options == null) || !options.AttachmentContentDisposition) { return(String.Empty); } var queryStringParameters = new NameValueCollection { { "disposition", "attachment" } }; return(queryStringParameters.ToQueryString()); }
/// <summary> /// Generates a fully qualified URL to the specified file path. /// </summary> /// <param name="instance">The object that provides methods to build URLs to Kentico content.</param> /// <param name="path">The virtual path of the file.</param> /// <param name="options">Options that affect the file URL.</param> /// <returns>The fully qualified URL to the file.</returns> /// <exception cref="ArgumentNullException"><paramref name="instance"/> is null.</exception> /// <exception cref="ArgumentException"><paramref name="path"/> is null, empty or contains query string parameters.</exception> public static string FileUrl(this ExtensionPoint <UrlHelper> instance, string path, FileUrlOptions options) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } if (string.IsNullOrEmpty(path)) { throw new ArgumentException("The file path needs to be provided."); } var absolutePath = instance.Target.Content(path); var queryString = GetUrlOptionsQueryString(options); return(BuildUrl(absolutePath, queryString)); }