0

I have a Sitecore C# MVC/.Net 4.5 application. I have a Javascript file that needs to be accessed by external sources.

As it is not part of any route, I get a 404 if I try to access it directly, even with the file existing.

How can I allow external access to this file?

6
  • 1
    so you have a javascript file which is accessed by a url for example right? and you want to add it to your views? or for example you want to download the file? Commented Feb 2, 2017 at 10:52
  • I currently cannot access it, I am getting a 404 because - I assume - there is no route that encompasses its path. I want to be able to access it, with a standard HTTP GET, in this case to include it in a page. Commented Feb 2, 2017 at 10:53
  • 1
    By default, files are served by the webserver and this logic happens before ASP.NET is even called. This sounds more like a web server problem than one for MVC - what web server are you using? Commented Feb 2, 2017 at 10:57
  • 1
    The common thing to do is place it under /Scripts, or else perhaps /Content. I have never seen that fail. Commented Feb 2, 2017 at 10:57
  • 1
    But then, Sitecore is an application not a web server, so we are back to square one. Commented Feb 2, 2017 at 11:08

1 Answer 1

2

By default you should be able to access those files. Check here.

Why CSS and JS files bypass Asp.Net MVC routes?

If not then you might have (or someone) altered the "Handlers" Section of your web.config.

Or have the setting added, which routes all static files from the mvc pipeline.

<modules runAllManagedModulesForAllRequests="true" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.