I have been noticing a weird problem on my site. I have managed to make my regular site load all the static content by defining STATIC_URL and STATIC_ROOT directives. However, when I go to mysite.com/admin, the admin site does not load any css at all.
Related
Say I made a website with Wordpress, and created a few pages say www.foo.com/bar1 and www.foo.com/bar2. I have no idea where they stored this, since there is no /bar1 and /bar2 directory. Unlike when I created a site from scratch and added new directories like /public_html/bar1.
So how do I configure it like this without Wordpress?
It depends on the technology\framework you're using. Google 'Routing'.
Example for Asp.Net: https://msdn.microsoft.com/en-us/library/cc668201.aspx
When you create a page using WordPress, your all page will have a dynamic content with same layout from page.php file which is a mandatory file of a theme and served according to the routes. You will not see the page.php in URL or page. WordPress saves your page title in database and servers it accordingly (check the permalink section of WordPress).
When you create a custom site from scratch you can do the same by creating a file and re-use it according to the routes. You don't need directory for that.
Note: File extensions like .php .html are removed using .htaccess file.
Maybe you can use a framework like ZK framework to create a div content and refresh it according to the request. This way, you may not have to update any url in your application. You just refresh an inner div by dynamicaly including a new view.
Maybe this would help:
https://www.zkoss.org/wiki/ZK_Component_Reference/Essential_Components/Include
I was wondering whether it is possible to deploy two ASP.Net MVC sites to do the following.
Main Website: contains all the controllers and views
CDN website: contains all the JavaScript and CSS (bundles JS and CSS that is consumed by the first site)
I was expecting that in the solution you would have two website projects. I think in debug mode this would work fine because the bundle names are consistent.
However, in production where you are not running in debug mode (turned off in web.config), the file names have a query parameter that varies e.g. http://www.test-domain.com/bundles/bootstrap?v=2Fz3B0iizV2NnnamQFrx-NbYJNTFeBJ2GM05SilbtQU1 (where bootstrap is the name of the bundle).
Does anyone know how to reference the bundles in the CDN website from the Razor views in the main website?
Answer
I realised that you don't have to include the query parameter for bundle name
If your MVC 5 project work well in Release mode in your local machine, it will work on Production too.
Only few more considerations you need to take care on production are :
Make sure CORS is enabled since you have js & css resources at different site(if domain name is different)
Make sure you references at MVC5 site having hosting views & back-end logic have correct references as you have created in CDN
Firewall/hosting port is allowed on both hosting machine to communicate.
Hope this helps.
BTW querystring appended to end of URL just make sure every request is differently served by Server not as cached, nothing to impact your application.
So we've got a project that our tutorial software exports as an HTML project. (Root has an index.html file, folders for js, css, etc)
Our support portal with Identity account management runs on ASP.NET MVC.
What I'd like is for the HTML project to be accessible, but you must login first.
I've gone about it two ways, unsuccessful both times:
I can put the HTML project in a static folder in the root of the ASP project. This way I can access it as domain.com/Test/Course/index.html. Everything works fine here, js and css are loaded properly, but it is not password protected.
I can put it in the App_Data folder, create a route to an action with the [Authorize] parameter that returns a FileResult, grabbing from the App_Data folder. This locks, and on login loads the index.html file, but all of the html files resources (accompanying js and css files) fail to load because the paths are wrong. It's pulling from App_Data, but index.html is now somewhere else, away from it's included js and css folders.
Any ideas would be greatly appreciated.
You'll want to take a look at these two questions:
How to do Forms Authentication on purely HTML pages using ASP.NET?
https://serverfault.com/questions/509879/protecting-static-content-with-forms-authentication-under-iis8
Basically - ASP.NET doesn't by default handle .html content because it's much faster to have IIS handle it directly. You need to configure it correctly to have it apply to .html files so that it can then apply its authentication model.
I am deploying a Web app consisting of both a static (marketing) site and dynamic app.
My goals are:
Separate dynamic and static content. Updating the static site should not take a code redeploy; updating the app shouldn't touch the static site.
Making it appear that it all lives at the same URL e.g. www.mysite.com
Think how Twitter works: http://twitter.com/privacy goes to a static page controlled by legal/marketing, while http://twitter.com/ goes to your feed.
I see a few options, could use some help:
Appliance: route based on URL like NetScaler / F5. Way too expensive, and doesn't play well in cloud deployments (Heroku/Jitsu/AWS/etc)
Proxy: static site deployed to a different URL (e.g. web.mysite.com), and dynamic site knows special paths and retrieves and caches the data. It works, but is complex and messy.
CORS: All static served from static site www.mysite.com, but loads application templates, JS, CSS, etc. from alternate api.mydata.com, and dynamic data via REST using CORS.
3 sounds nice, but worried about CORS browser support and still get some pollution across static and dynamic sites.
FWIW, implementing dynamic in nodejs, but could just as easily apply to RoR or even JavaEE.
If you don't mind putting your static content in a specific subdirectory (like twitter's /privacy), then I think all you need to do is add that directory to your .gitignore (or other VCS ignore file), and deploy your app without that subdirectory. You'll need some other process to upload changes to the static content.
As for serving it, you should have a front end webserver (apache or ningx probably) or other proxy server serving all your static content anyway, including images and js/css from the dynamic part of your app. If your static site is .html etc anyway, then it should get served the same way, without touching your running application at all. You could also be more explicit in the web or proxy server configuration that it should serve everything in that subdirectory without forwarding the request to your application.
I have a web server that has existing pages in it that are created with basic static HTML. I want to leave them alone, but augment the site with some ASP.NET MVC pages. I want these pages to be reachable via the MVC URL routing mechanism. But, ideally, I want to preserve the old static pages URLs without having to bring all those static pages into the MVC app. What's the best way to accomplish this?
Static files such as .html pages that exist on disc will be directly served by the web server. If you are hosting your application in II7 integrated mode you could try adding the following route:
routes.IgnoreRoute("{file}.html");
By default routing is not applied when a physical file exists which could be turned off by using routes.RouteExistingFiles = true;.