Adding Other Projects(Blog Engine) inside an existing MVC5 Azure WebApp - c#

I am trying to add BlogEngine.NET(web) to my existing MVC5 project (which is running as an azure website) partly based on these instructions. I have downloaded/extracted the entire web project folder and included it as a folder to my existing MVC Project.
My controller has the below code
public ActionResult Blog()
{
var path = Server.MapPath("~/BlogEngine/default");
return View(path);
}
But, I receive the error:
....BlogEngine\default' or its master was not found or no view engine
supports the searched locations.
by reading this, I understand why this error occurs. I just want some pointers on how to add the Blog engine to my existing project.
EDIT:
this is exactly what I want to achieve, but azure is not helping(the whole point of me choosing to use azure websites instead of AzureVMs is to shy away from the responsibility of keeping that VM up and running), so looking at the other options at hand, like tweaking my MVC.

goto manage.windowsazure.com
select the webapp
Navigate to the Configuration Tab
Scroll Down to Virtual Applications and Directories
Add the Path of the Directory there and Select the Application checkbox.
Hit Save.

Related

Is there a way to include images outside of my project in ASP.NET MVC 5?

I have a project that is written using C# on the top of ASP.NET MVC 5 framework.
I have images located on C:/web_images that I want to make accessible from my app. In my views, I want to be able to write ~/images/abc.jpg but my app would render the image located on C:/web_images/abc.jpg.
In the new ASP.NET Core framework, the same thing can be done using static files( by adding the following to the Configure method in the Startup class.)
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = blobFileProvider, //new PhysicalFileProvider("c:/web_images"),
RequestPath = "/images"
});
How can I create this virtual path using ASP.NET MVC 5?
User browser can't access directly to webserver drive (c:).
The best way to do it is to create a .ashx who can allow users (views rendreds) to download files.
view exemple:
<img src="~/ProcessImage.ashx?filename=image1.pgp"/>
I hope this help you.
First option that came to my mind is to use Owin and get nuget package for serving static files, like this one Microsoft.Owin.StaticFiles.
Second, more invasive approach is to create Symlink to given folder: Symlink tutorial
Third option: Host on IIS and create virtual directory.

Stripping a C# app down to its static web app

We are separating our front end from our back end (C#.NET MVC) so that back-end dev does not block front-end. Instead of a zillion local database updates, I'll be hitting an API.
I've been working in VS up till now, but wish to work in another editor, and be able launch the front-end in a browser directly.
Except that the index page is index.cshtml. There's nothing of note in the index file that requires it to be cshtml, so I could convert it to .html - the only problem is, now launching the app in VS fails because it is only looking for a cshtml file to start, i.e.:
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
etc.
My question is: what can I do to modify index.cshtml or the server, so that I can load the app in a browser without having to run it through Visual Studio?
This is the current structure in VS, most of which I hope to dispense with:
App.Data.EntityFramework
App.Data.Sql
App.Domain
App.DomainEntities
App.Presentation.Web
App_Data
App_Start
Areas
Content
CSS
js
apps
dashboard
controllers
views << dashboard files
store << 90% of my files are here
controllers
views
services
etc.
Controllers
ControllersApi
Models
Providers
Results
Views
Home
index.cshtml << actual start page
This is where I go to start the app:
https://localhost:44337/#/dashboard

Changing URL in asp.net

I have an asp.net website. The Admin panel is located here:
mysite.com/manager
I want to change this to:
mysite.com/admin
There is no file named manager in the website files and I'm unsure how to make this change or locate the manager source file.
Firstly, it's unlikely to be related to a database in anyway.
Sounds like your project is using MVC and Routing:
The ASP.NET Routing module is responsible for mapping incoming browser requests to particular MVC controller actions
If so, your web project will have a folder called "Controllers" and within that there will be a file called "ManagerController.cs".
Within this file, you'll see a method that looks like:
public virtual ActionResult Index()
{
// some code maybe
return View();
}
This is what will be called when that URL is hit.
You may also want to search for a file called RouteConfig.cs, which is located in the App_Start folder, where any non-standard routes will be configured.
To make the change, you can copy and rename ManagerController.cs to AdminController.cs and MVC will work it's magic as the default routing will search for that file instead.

Directory in MVC3 Project

I have a "Tools" area of the MVC3 site I'm currently working on. One of the tools I'm integrating on the site I need to run in a virtual directory. Setting up a virtual directory under the /Tools folder works fine for the app itself, but for navigation to /Tools/, I'm getting "Directory listing not allowed". How do I tell IIS to let MVC routes handle this URL?
We'll be using IIS6 in production, so it's important for it to work with that.
Thanks in advance.
EDIT: For clarity, here's the setup:
/Tools/RoutedTool1
/Tools/ToolInVirtualDirectory
/Tools/RoutedTool2
/Tools/
The routes for the routed tools work fine, but since I had to create a directory under the root to setup the "ToolInVirtualDirectory", IIS is hijacking the "/Tools/" request and trying to send it to the directory, ignoring the route.
You should set routes.RouteExistingFiles = true in Global.asax.cs.
Remember that since this property plays at global level you have to ignore the css files and other stuff you don't need to handle by the routing infrstructure before setting this. For more idea please refer this post.
In your RegisterRoutes section in Global.asax, you add ignore routes that the routing system ignores. There should already be an example for .axd's in the config.

Why isn't my Route.Ignore working on this static file in my ASP.NET MVC application?

Background
I have a PDF file located (under my Project) in an Assets > Documents folder:
When my application gets deployed, it gets deployed to a particular folder on the domain. For example, http://www.domain.com/MyAppFolder. I want to be able to access this PDF file by linking to http://www.domain.com/MyAppFolder/Assets/Documents/EZTrac_UserGuide_NewSys.pdf
Problem
I can't seem to get the routing correct for this, as it keeps trying to route this request to a controller. Here is the modification I made to the routing:
routes.IgnoreRoute("MyAppFolder/Assets/Documents/EZTrac_UserGuide_NewSys.pdf");
But this is the result that I get:
The IControllerFactory
'EZTrac.DependencyResolution.ControllerFactory'
did not return a controller for a
controller named 'Assets'.
Try removing the MyAppFolder from your routes.
routes.IgnoreRoute("Assets/Documents/EZTrac_UserGuide_NewSys.pdf");

Categories