angularjs - Refresh html mode angular app with deep linking -


Like many people like me, I'm struggling to refresh the page to work with my Connel app .

I am using angular / need / webpati I extended it

I kept this project with it

Here is the place where I am present I sit in

I have route setup, they are in HTML mode, they work on site navigation. Refresh was causing problems In order to relocate the failures in the index, I setup code Gobal.asax.cs. Define the base page (/ phone)

This is my passcode code

  define ('' ('$ RouteProvider', 'Provide' '', '$ LocationProvider', function ($), 'app', 'angular', 'app', 'angular root' route provider, $ $, $ location provider) {// $ provide.decorator ('$ ssniffer'), Function ($ representative) {// $ delegate.history = false; // return $ representative; //}); $ Route provider when ('/', {redirectTo: '/ phones'}). When ('/ phone', {templateUrl: '../Web/Templates/partials/_phones.html', Controller: 'Phone List'}). ('/ Phones /: phoneId', {templateUrl: '../Web/Templates/partials/_phone-detail.html', Controller: 'PhoneDetail'}); // otherwise ({// redirectTo: '/ phones' //}); // Enable html5mode for pushstate ('#' - less URL) // $ locationProvider.hashPrefix ('!'); $ LocationProvider.html5Mode (true);}]); MyApp;};);   

My global .asax.cs

  public class WebApiApplication: System.Web.HttpApplication {private const string ROOT_DOCUMENT = "index.html"; Protected Zero application_Start () {global configuration Configure (WebApiConfig.Register); } Secure zero application_BeginRequest (Object Sender, EventArgs e) {string url = Request.Url.LocalPath; String [] newURL = new string [1]; NewURL [0] = ROOT_DOCUMENT; If (! System.io.file.exist (reference surfer.mappath (url))) reference. Reiter path (Rudo deocoumement); }}   

and my index.html

  & lt ;; Doctype html & gt; & Lt; Html lang = "en" ng-app = "myApp" & gt; & Lt; Top & gt; & Lt; Title & gt; Angular-essential sample app & lt; / Title & gt; & Lt; Meta name = "viewport" content = "width = device-width, initial-scale = 1.0" & gt; & Lt ;! - & lt; Script data-main = "script / app / main" src = "script / lib / require.js" & gt; & Lt; / Script & gt; - & gt; & Lt; Link rel = "stylesheet" type = "text / css" media = "all" href = "content / css / app.css" /> & Lt; Link rel = "stylesheet" type = "text / css" media = "all" href = "content / css / bootstrap.css" /> & Lt; Link rel = "stylesheet" type = "text / css" media = "all" href = "content / css / bootstrap-responsive.css" /> & Lt; Base href = "/" & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div class = "container-liquid" & gt; & Lt; P & gt; Single Page Web App & lt; / P & gt; & Lt; Div ng-view & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Script data-main = "scripts / app / main" src = "scripts / Lib / needs.js" & gt; & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;    

should resolve this problem - change continuous definition:

  private pronoun string ROOT_DOCUMENT = "/index.html"; // Private Constring instead of ROOT_DOCUMENT = "index.html";   

Check it out here: (Scroll down to ASP.Net C # Rewrites ) View that snippet:

  private pronoun string ROOT_DOCUMENT = "/default.aspx"; Protected Zero application_BeginRequest (Object Sender, EventArgs e) {string url = Request.Url.LocalPath; If (! System.io.file.exist (reference surfer.mappath (url))) reference. Reiter path (Rudo deocoumement); }   

Note, I would recommend to change the Application_BeginRequest to properly manage API requests like this:

 < Code> Protected Zero application_BeginRequest (Object Sender, EventEurge E) {var path = Requests. Url.solitepath; Var is API = path. Wires ("/ API", String Communications, Inventory Culture Ignore Case); If (ip) {return; } ...    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -