MVC6 Load razor views from database - asp.net

We are working on ASP.NET MVC 6 project and it's necessary to load and then compile Razor views from an external source (Azure document database).
I see in other SO posts (<= MVC 5) it was possible to create and register a custom VirtualPathProvider which can take view content from DB or resource DLLs (for example).
What are the options for MVC 6 ?

Technically not implemented yet. This is after all a rewrite and not just a set of new features.
I found a thread on GitHub which talk about a way to get what you need.
Basically, it's about providing your own implementation of IFileProvider.
I have virtually no experience in implementing this but I think that if you have time to spare, this is definitely the way to go.

A bit late to the party, but if you are still looking at this I have just posted a sample project to GitHub showing how to store your .cshtml in Azure Blob storage using ASP.NET 5 / MVC 6.
#Maxime Rouiller - MVP is correct that you need to provide a custom IFileProvider. My sample is using rc1-final and working. Looking at the aspnet project though, this may change subtly later (will allow multiple providers to be registered)
A blog post write up on this should be coming in the next few days too.

Related

Asp.Net MVC Application split into multiple assemblies

I am pretty new to mvc but have already read a few books.
What I want to archive is:
-> Having the main asp.net app in its own project.
-> Every modul (for example forum modul) is hosted in a regular dll (including its controller, models and views).
I've looked into the issue of hosting controllers in different assemblies. This is actually easy to handle. But what I do have issues with are the views.
I could not find any resource regarding how to tell mvc that he should look for the views in this namespace the the other view in the other namespace.
Best regards
Simon
Have you imported the projects/assemblies in the project you need to use them?
Look in the References folder. They must be there so you can use them.
I am not quite clear why you would use this style of architecture, but again that's your choice.
What I can confirm is that it is not going to be as useful as you think.
A detailed explanation is here

Should i create an Empty Web Application or Web API Web Application template? - VB.net

I wanted to build a VB.net web application using MS Visual Studio 2015. Someone suggested me to create a Web API instead of MVC project if i'm also planning to create a mobile app later on. I may use angularjs in my project so controllers will surely be used, so what should i choose when creating the project in the first place?
Because when i created a web project: File=>New Project=>ASP.net Web Application=>Empty..there are no folders for Controllers, Model, etc. Do i have to create a Controller folder on my own?
Or should i do this: File=>New Project=>ASP.net Web Application=>Web API..? sorry if its a silly question. its just that i'm afraid that if i chose the wrong project now, it'll affect the development later on.
Answer to your question mainly depends on your choice and needs,
for example
In Case of an empty project as name defines you will have nothing else web.config.
Benefits of it:
here you can define, design your own structure. you can either make
it simple 3 tier or you can make it WEBAPI application. it's all up
to you.
however in the case of choosing Webapi template you will have a prebuilt structure which can help you out for initial understanding
https://docs.asp.net/en/latest/tutorials/first-web-api.html
benefits of it
You will get predefine template and structure.
you can utilize of webapi's which further isolate you backend logic from the frontend.
as you are also planning to create the mobile app. and using front end as angular, so in that case, webapi may come handy.
as the whole world is moving towards webapi, so i will recommend you to use it. please refer https://blogs.msdn.microsoft.com/martinkearn/2015/01/05/introduction-to-rest-and-net-web-api/
so down the line it all depend on you if you want to build you application for the stretch and take full control of it regarding structuring backend etc.. then go with empty else go with Microsoft pre-define template
Thanks,
Ajay Kotnala

ASP.NET Core Web Api automatic help pages

In previous versions of ASP.NET, when I created Web Api 2, visual studio automatically wired up automatic generation of documentation for the API.
It's also explained here:
http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages
I'm writing a new project and I've decided to do it with ASP.NET Core, but I don't see anything similar to what existed in the previous versions that generates the documentation from the API (I'm also guessing that's its a bit different since all controllers now inherit from the same Controller class).
But, is there some way to have help files generated for ASP.NET Core APIs?
The functionality you want is at https://github.com/domaindrivendev/Swashbuckle
The following link provides an example of how to configure and use the well-designed utility
https://damienbod.com/2015/12/13/asp-net-5-mvc-6-api-documentation-using-swagger/
John Davidson made a good post showing how to generate Swagger documentation - that is useful and great.
But if you want to stick to ASP.Net MVC 5 - Api Explorer documentation, you should have a look to that excellent blog post :
https://andrewlock.net/introduction-to-the-apiexplorer-in-asp-net-core/

Design decision between backbone.js or Spring MVC

I have to develop an application which takes XML reports stored in File System parse it and put it into database and display the reports by querying the database in various MIME types(XML,JSON,RSS and HTML). So what I have done till now is parsed the XML reports in the file system ,setup schema for database in MongoDB,put data in database using Spring-data and also managed to have a web service which shows rough draft of reports in XML,JSON and RSS feed.Now I want to display the reports in HTML as well and my supervisor suggested me to use Backbone.js to dispaly it in HTML format by calling the web service.Kindly advice me to choose b/w Backbone.js or write another Spring MVC web service which generates reports in HTML.
Thanks in advance
Swaraj
What you are asking are two different things and choosing between them.
You have to know what your overall objective is with the webapp is and what framework is best for it.
Short answer, Spring MVC integrates with Dojo.js right out of the box, which might do what you need to do, but since your supervisor is suggesting otherwise your options are:
Use Spring MVC to construct and display the data in the HTML using what ever render of your choice.
Or
Build out your Spring MVC wepapp API so that you can use a JavaScript MVC framework, such as Backbone.js or one of the many others (see TODOMVC for samples), to interact with your spring controllers.
Option 1 might be easy enough, used in conjunction with JavaScript or jQuery and plugins
Option 2 would be good if your webapp is complex and will be mostly a SPA (single page app) that utilizes a lot of JavaScript and you want a way to organize your js code better. See JavaScript MVC diagram for an example of how it works.

Protecting Vidoes from downloading in asp.net

Language: C#
Skill: Beginner
Tool: Visual Studio 2010
Technology: ASP.NET 4.0 WebForms
Hello StackOverflow,
I intend to develop an asp.net web app for my final year project (to complete my bachelors degree) ,Scenario is that I want to allow users of the app to post videos(vidz) and these vidz can only be watched by the user who is allowed by the owner of the vidz ,further more the viewer should only be able to view the vidoes...
I came to know about the DRM solution of silverlight but i think its comes with some cost ,so for me its unaffordable..
it's a bit of a kludge but I used the approach below to protect images from being downloaded without the right cookie being set ... a variation could be used to hide the video from random attempts.
if you need to be really certain that it's protected then a solution like PlayReady is going to be the answer, but if you just need to avoid casual "fly-by" then this might be enough
http://blog.offbeatmammal.com/post/2006/06/30/Using-ASPNET-to-restrict-access-to-images.aspx
If you're using ASP.Net MVC I recommend you to take a look at this project:
http://mvcresumingactions.codeplex.com/
By adding authorization layer on top of your controller you can easily manage access to that controller based on your own logic (Like members who have access to that video). For more information about authorization you can take a look at:
http://nerddinnerbook.s3.amazonaws.com/Part9.htm
I know this is little bit generic but I hope this can give you some clue :-)

Resources