Iago Rodríguez
Iago Rodríguez

Reputation: 376

AngularJS + ASP.NET MVC: routing URLs without corresponding physical view

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.

Upvotes: 0

Views: 146

Answers (1)

Yang Zhang
Yang Zhang

Reputation: 4570

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

Upvotes: 1

Related Questions