Allow HTML files in Asp.Net MVC application - asp.net

I'm building an application using ASP.NET MVC and Angular JS.
The point is to use angular for all web things and ASP.Net for backend stuff. In other words, I kind of bypassed the whole view of MVC and used a single view. Angular will get his files from the Content folder.
Those files are .html files and this seem to be a problem because I always get a 404.
Actually I also tried renaming it to .cshtml but that does not fix the problem..
Do you know of any tricks (well, clean ones of course) to let my angular app download it's views and be happy?
Thanks.
Georges

The problem most likely is in the fact that ASP.NET MVC tries to filter the request through the routing mechanism, and obviously there is no route for HTML files. Try adding the following to the routes registration method:
routes.IgnoreRoute("{file}.html");

Related

Using a view specific connection string in ASP.NET MVC

I upgraded an old website from ASP.NET to MVC recently and now I am running into a user login problem with one of my views. In the old situation I would have a separate web.config in the folder for that page that would set the connection string specifically for that page. Now I would like to do that in ASP.NET MVC as well, however the web.config in the specific views folder does not work. I also tried to change the web.config in the views folder, but maybe I did this in a wrong way because it did not work.
Does anyone have an idea how to accomplish the same result in ASP.NET MVC as I had in ASP.NET?
Why not use a separate configuration file, as explained in this MSDN article?
https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/connection-strings-and-configuration-files

Looking for Server Side Rendering using VUEJS having ASPX page and site hosting on IIS7

We have our existing pages in ASPX and site is hosted on IIS7 server.
We are looking for revamping/design the pages in VUEJS 2.0.
We are able to get VueJS code integrated with existing ASPX pages by getting build.js generated (production) and referring the same on ASPX page and page will be having the Target element. This all is client side rendering.
Now, we want the same in SSR. That mean to be complete HTML code rendered on the page before being served to the client (browser).
This clearly indicates we need to setup NodeServer, which can be called up by ASP.NET to get the VUEJS code rendered and added on ASPX page before it's being served to the Client (Browser). Please correct me If I am wrong. Here we are looking for a dynamic webages (Not the static one with prerendering or static generation)
We have started looking up for NUXT.JS as one of the options. But this is recommended to be used for the apps hosted for NodeServer.
ref:https://github.com/MarkPieszak/aspnetcore-Vue-starter/issues/67
1: https://github.com/MarkPieszak/aspnetcore-Vue-starter/issues/67
Other big challenge going with Nuxt is, they are likely launching Nuxt2.js version, which may or may not have breaking changes. https://medium.com/nuxt/nuxt-2-is-coming-oh-yeah-212c1a9e1a67
Next option is to looking for following:
https://github.com/MarkPieszak/aspnetcore-Vue-starter
https://github.com/vuejs/vue-hackernews-2.0
http://mgyongyosi.com/2016/Vuejs-server-side-rendering-with-aspnet-core/
Above links mentions using ASP.net core API Microsoft.AspNetCore.SpaServices.Webpack.
I believe you must have faced this situation and reached to an optimal solution. I am looking for suggestions from veterans have achieved the same, what path to be followed?
IF this can be achieved at all? and what are the challenges I should look forward?
Thanks

Hiding http file extension without using MVC controller

I am using basic asp.net web application project template, because I want to move away from MVC into SPA.
Most of my pages will just be basic html files that will interact with the server through ajax calls. That said I want to hide the .html extension, but I don't want to create controllers just to hide this, which is too much of an overkill.
Of another note, I am using Azure as well, so setting this up on IIS directly is not going to work, as I would not be able to scale the administration nicely.
So how can I hide the html extensions without such a heavy layer as an MVC controller?
This sounds like a job for Url Routing
Url Routing allows you to intercept a request and then determine how to service it. It is how MVC does it and has many other useful benefits. If the router isn't able to service it, it falls back to the default ASP.NET pipeline processing, and then IIS.

Upgrade classic ASP to MVC 4.0

I'm in the process of upgrading from classic ASP to MVC 4.0. MVC projects have a unique folder structure with modules, views, and controllers. Our classic ASP website is very well indexed in search engines, and uses all friendly URLs (some mapped to existing folders and removing page extensions, and others mapped for SEO and not to the folder containing the files), using Rewrite Rules in web.config. I need to maintain all the current URLs, but they all map into different folders than the MVC project will. I'd like the MVC project to remain in the folder structure defined in the default project, but also need to continue using the existing URLs.
What is the best way to maintain the current URLs of the site when moving to MVC? Is custom routing the only/best way to handle this?
I gues there are four ways to do rewriting urls, no matter which one you use, you need to do some changes. For example you should change the way you read the url parameters.
I follow this tutorial http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
It helps alot

Get Flex modules from ASP MVC

We´re developing an ASP MVC application witch the View (aspx) has a Flex embed. This aspx/flex view is composed by a flex application and several modules.
So, when we call the application url (http://localhost:9090/MyProject/Flex/Index), the server invoke the method the will return the ActionResult that represents this action, in this case the ~/Views/Flex/Index.aspx (with the Flex app). However when the ModuleLoader, in the Flex application, try to load a module an error occurs. The problem is that the Flex application can´t directly access the modules folder (~/Views/Flex/modules/module.swf).
Are there any way to get the module through an ASP MVC action? Or the best approach is to allow the access to this folder through web.config?
Again, sorry for the poor english!
Thanks,
André
The views folder should be used for aspx/ascx views. You'll want to put .swf files in in a content folder like ~/Content/modules/module.swf.

Resources