How to configure Azure to always show index.html - angularjs

I am hosting a web application on Azure - I deployed it yesterday by just copying all the required files into wwwroot.
It sort of works - except that it behaves differently than when it did when I just ran npm start locally (it's an Angular 2 app, with config copied from the 5 min quickstart guide) - when I ran it locally, I could manually enter any URL which was handled by routers and it did load, and on Azure it throws a 404 (also happens when I just refresh any page besides the home page) - I presume that somehow when I ran it locally, it figured out that I always need to load index.html, regardless of the actual URL, and let the router handle everything. How can I replicate this behavior on Azure?

Your Azure WebApp is running on an IIS instance by default.
If you want to handle the Html5 Mode(without the hashbang) then you have to create a Web.Config file and define a rewrite.
See How do I configure IIS for URL Rewriting an AngularJS application in HTML5 mode?
Dont forget to set <base href="/"> in the <head> of your index.html. Otherwise it wont work.

I think you will probably have to use URL Rewrite for this, unless you are using MVC to deliver the page. Here is a previous answer that will help you configure URL Rewrite. It is talking about WordPress, but it should point you in the right direction.

You should try checking the Azure portal under the Application Settings for the Web Application if .index.html is included in the List of Default Document option
I would be glad if you can rephrase your Question to understand it more.

Related

I'm receiving an error accessing api calls when deployed to a subfolder

I have developed a web app using ABP.IO version 5.0 (also same issue using 4.4.3).NET Core Razor pages. In the development environment everything works fine. If I deploy the application to IIS as a root-level site (access URL like https://{my site}), everything works fine. I deploy it as an application under a root-level site (access URL like https://{parent site}/{my site}) I can access the login page and hit the Identity Server, but all subsequent calls that hit the API fail. The URL for calls to the API drop the {my site} portion of the URL and I get a 404 error. The calls to the API look like https://{parent site}/api/{controller}/{method} instead of https://{parent site}/{my site}/api/{controller}/{method}.
I found a setting for the appsettings.json file (AppSelfURL) that I thought might help resolve the issue but it did nothing.
Is there a setting that forces the app to retain the complete base URL when making the calls to the API?
ABP supports sub-application deployment.
You can check this: https://github.com/abpframework/abp/pull/4101

How do I change the deployment web page in Google App Engine?

I'm trying to change the entry web page that gets launched in my Google App Engine deployment. It's a simple J2E web project, using IntelliJ with Cloud Code plugin. The default deployment points to 'index.jsp', which gets automatically created with the project. I want to change that, to point to a custom form I have built, e.g. 'form.xhtml'.
Steps I've been through so far...
Created base Google App Engine (Standard)
Configured GAE localhost
Configured GAE deployment server
I can do this easily on the localhost server, by just changing the server URL, e.g. from http://localhost:8080/ to http://localhost:8080/Ex_1.xhtml
I can't work out how to change this on the deployment server though. There's no URL option like there is with localhost. As a result, when I deploy my code it still just launches the default index.jsp.
I've looked through the GAE deployment descriptor documentation, but it doesn't mention how to do this. I'm sure it's a very simple change, I just can't put my finger on it.
Can anyone help?
I've resolved this, in case anyone else has a similar issue. You need to add the 'entry page' into web-xml, using the 'welcome-file-lists' tag. For some reason Eclipse adds this automatically but IntelliJ doesn't. If this isn't added, the App Engine deployment server points to the default index.jsp
<welcome-file-list>
<welcome-file>my-entry-page.xhtml</welcome-file>
</welcome-file-list>

Static hosting - ReactJS app on Azure Blob storage with Azure CDN

I would like to host my ReactJS app as static on Azure Blob. The problem is Azure Blob doesn't support default document. To overcome this, I have set Azure CDN with URL Rewrite rules
for the first source pattern, set to ((?:[^\?]*/)?)($|\?.*)
for the first destination pattern, set to $1index.html$2
for the second source pattern, set to
((?:[^\?]*/)?[^\?/.]+)($|\?.*)
for the second destination pattern, set to $1/index.html$2
This is from the Hao's tutorial
This successfully resolves myapp.azureedge.net but when the client-side routing is used directly e.g. myapp.azureedge.net\react\route the app will return ResourceNotFound.
Meaning when the user inputs myapp.azureedge.net\react\route as his URL and tries to navigate to the page, he will get an error.
I suspect I need to redirect every path, that is not to a static specific file, to index.html. However, I do not know if that's the right solution or how to achieve it
Thank you for Any help!
Azure CDN supports static website hosting now. More information here:
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website
You can host a single page app without using URL rewrites by setting the default document and the error document to be index.html
I encountered the similar issue before. Assuming that the structure of your static files under Azure Blob container looks like this:
Note: The cdn is the container name.
You could configure the following URL Rewrite rules for setting default page and rewriting all requests to index.html along with the possible query string and your images and scripts under cdn/scripts and cdn/images could correctly accessed.
Additionally, you could use Azure Web App to host your static website and choose the proper pricing tier. Details you could follow Pricing calculator.
There is a new Azure static web app service, currently in preview mode but it is super easy to deploy a modern frontend SPA. You can set up a fallback route (route.json) to redirect everything to index.html, you can see more here: https://learn.microsoft.com/en-us/azure/static-web-apps/

How to get BlogEngine.NET to run outside of a local environment?

I am trying to run BlogEngine.NET. It works fine locally in Visual Studio but whenever I publish it outside of my local computer none of the posts are showing up.
I think this is because none of the scripts or CSS are being loaded (the posts are done via AngularJS). I've made sure that the read and write permissions are allowed in IIS so I know that isn't the problem.
I believe that AngularJS isn't loading properly, as when I go to the admin panel the url returned with the 404 error is this:
8926/admin/%7B%7BSiteVars.RelativeWebRoot%7D%7Dadmin/#/dashboard
instead of:
8926/admin/#/dashboard
Even If I manually take out all of the %7B%7BSiteVars.RelativeWebRoot%7D%7Dadmin text, the posts still don't show up as they do locally which leads me to believe the posts are also tied to AngularJS as well.
Does anyone know how to fix this? This may not be a BlogEngine.NET problem as much as it is just a loading of Javascript and CSS problem inside of IIS
The documentation for my project is here.
BlogEngine.Net had moved to GitHub that is where the latest updates are at.
Best to go here:
https://github.com/rxtur/BlogEngine.NET
and try again with a fresh install.
I have a fresh install working with no issues here:
http://blogengine07.azurewebsites.net
Took a total of around 30 mins to it it 100% up and running, creating new web app service,database, change web.config, publish to Azure, and making some changes in settings.
What web host are you using to host your website?
You can also try Azure Web App Service for free here:
https://azure.microsoft.com/en-us/try/app-service/web/?language=cs
If you can get it to work there but not at your current web host then that points to a web server issue, since you are able to run it locally and on Azure.
Hope this helps.
Have a great Day!
Brian Keith Davis

Access Custom Admin Page on AppEngine Development Server

I'm using Appengine and I want to write a custom admin page for myself. How can I view the custom admin page on the development server (on my localhost)?
The localhost console does not seem to have a link to it (even though it's defined in the .yaml and the page is working properly).
Thanks
Enter the URL in your browser, i.e.
http://localhost:8080/MyAdminPage.html

Resources