0

Context We have a web app using AngularJS with ASP.NET MVC. It aims to replicate a file-system structure through URLs, like this:

http://(site1)//rootFolder//NFolders//File  

For views in Angular, we are using stateProvider, with different states associated to existing views in disk (.cshtml files).

The problem issues when we request a file or folder from the browser and we try to serve a virtual view that doesn't really exist. We have just been able to achieve it with a full postback and some hacks, making a complete reload on each file/folder request.

Question: Is there a way of achieving that in Angular? Other way, the request for different URLs which don't have either their corresponding physical view as a file or any state in stateProvider, handling them with Angular and customizing a specific view which would deal with disk routes requested by URL?

RE-EDIT We will have:

RE-QUESTION: is it possible to handle this "virtual" URLs without having a physical view behind for folders or files? Our idea is to have one unique view called siteController which would control all the sites, and paths to folders and files.

1 Answer 1

1

I would suggest you define rootFolder/NFolders/File as parameters. Then you can have a html file as the view template to populate data from server.

Have a look at this link

https://github.com/angular-ui/ui-router/wiki/URL-Routing#stateparams-service

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks very much for the answer. But the problem with using parameters is that first part of the URL is variable: website/(site1/(rootFolder)//(NFolders)//File: site1, could be site2, siteN, etc. Please see my reedition on the question in order to have futher explanations on the structure we are using.

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.