I'm using a custom configuration section in my web.config in an ASP.NET MVC 5 project. It works perfectly fine, until I try to download a file via a link:
<a href="@Url.Action("Download", new { id = Model.Id })">...
Here's how I'm handling the download in the controller:
return new FileStreamResult(myStream, "application/octet-stream")
{
FileDownloadName = "MyFile.someExt"
}
I will reiterate that my custom config works fine, except when I click the download link mentioned above. I then get an error:
Unrecognized element 'link'.
link
being a child element of my custom config section, i.e.,
<navigationMenu>
<link ...
Edit 1: It may be useful info that I'm accessing my custom config section in this manner:
XDocument.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile)
.Root.Element("navigationMenu");
However, it is properly registered in the <configSections />
of the web.config, i.e.,
<!-- From web.config -->
<section name="navigationMenu" type="MySite.Helpers.NavigationMenuSection, MySite" />
// With the config section class declared like so:
public class NavigationMenuSection : ConfigurationSection
{ }
But i'll stress again that this works fine, until I click the download link. Why would the content-type cause issues? Can't really wrap my head around the issue...