Can not find index view when deploying to production? - c#

I'm hit a problem when attempting to deploy a MVC app as a sub-application of an existing ASP.NET 3.5 app (non MVC). The error is:
The view 'index' or its master could not be found. The following locations were searched:
~/Views/employment/index.aspx
~/Views/employment/index.ascx
~/Views/Shared/index.aspx
~/Views/Shared/index.ascx
The application works fine when running inside of visual studio web developer express SP1 and also works when configured as the top level web site.
I'm developing under XP (IIS 6ish) so I've already configured the wildcard mappings etc. The MVC app is configured as a virtual folder directly underneath the root web site (http://localhost/ROHAS where ROHAS is the virtual folder pointing to my MVC solution). I've also tried adding routes in the global.asax.cs to compensate for the sub application's virtual path:
routes.MapRoute("NetPortal", // Route name<br>
"localhost/rohas/{controller}/{action}/{id}");
and also
routes.MapRoute("NetPortal", // Route name<br>
"rohas/{controller}/{action}/{id}");
I've even tried adding another virtual folder that just points to the Views folder in my MVC solution.
However, I still get the error detailed above.

You have to create a Virtual Directory in the website youre using the MVC project in, with the name 'Views', which points to the Views directory in your MVC project. Make sure to just create a VD with only 'Read' access in IIS Manager, and make also sure you do not have a Application for the VD.
(VD -> Properties -> Make sure the application section is greyed out)

It appears that your view file is missing. Your employmentController is attempting to return a view/partial view named index.aspx/index.ascx which cannot be found. You should place your view in the ~/Views/employment folder of your mvc.net application directory. Or it can be placed in the ~/Views/Shared/ folder
The error has nothing to do with your routing in your global.ascx file

Related

Why am Igetting the error "Could not load type 'CADE.main.index'." on a new server when I'm using the same code on all other instances, how fix it?

I just checked out my "mixed" (asp classic and .Net) web site source from SVN on a new Windows 2019 Server. When I go to the logon page (.asp classic), it's fine but when you logon and call the main page (.aspx) it throws the error: "Could not load type 'CADE.main.index'" and displays:
Line 1: <%# Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="CADE.main.index" %>
This SVN code is running on 15+ servers, including one 2019 Server. The code behind looks like:
namespace CADE.main
{
public partial class index : BasePage // Override with BasePage
{
IIS and everything under Application Development is installed. IIS serves .asp, .txt, .gif, .png, even .Net handlers (.ashx) and web services (.asmx), just not the aspx pages.
So, I rebuilt the solution with VS2019 and published it, gave administrator permissions on the app pool, gave "Everyone" full permissions on the entire web, deleted the bin directories in both the source and web locations, ensured output path was bin/, cleaned the project, don't think I should change CodeBehind to CodeFile, and tried about every other thing that people have suggested on this web site but nothing has eliminated the error.
Question: How do I fix this error so the .aspx pages loads?
EDIT #1: 15 hours after post
I'm not sure but with this information maybe this should be a new post.
This error ONLY happens on the second web site. IIS is serving two web sites, separating them by host name (web1.com vs. web2.com) in bindings. They both point at the same file structure. Web1's subdirectories are natural while Web2's subdirectories are virtual directories that point to Web1's.
Web1: Normal IIS web
wwwroot
LMW (subweb, LMW/Main/index.aspx is page in question, but works here)
Web2: Second web in IIS, based on host name, uses Web1's folders as virtual directories.
wwwroot
WEB2 (folder under wwwroot)
LMW (virtual directory points to Web1/wwwroot/LMW. LMW/Main/index.aspx gives the error here)
Question: Why doesn't the .aspx work when it's a virtual directory?... it's the same file as is in Web 1?
EDIT #2
It is working but I don't know what I did to fix it. I'm sure I changed something but I don't know what it was. So, I created another web like web #2, New web folder under wwwroot with LMW a virtual directory pointing to Web1/wwwroot/LMW! I'm seriously missing something, Any ideas?
These errors occur if the .aspx page or the Global.asax page contains a reference to a code-behind module and if the application has not been built.
You could try the below method to build the application:
Use the C# command-line compiler (CSC.exe) to run the following command:
csc /t:library /r:System.web.dll /out:mydll.dll myfile.cs
OR
In Microsoft Visual Studio .NET, click Build on the Build menu.
Also try changing CodeBehind="index.aspx.cs" to CodeFile="index.aspx.cs". This change is required when you change project type from website to webapplication or vice versa.
make sure you install the .ne framework feature of iis.
I actually created a brand new web that used a Virtual Directory for it's codebase that is the same code as the other webs.
Index.aspx resides in the /lmw/main directory. I had created an Application on that folder when I was creating the other applications in the web. So, I removed the "Application" from /lmw/main and it worked.

How does Asp.net 4.5.x MVC work with Angular 2?

I'm learning to use Angular 2 with asp.net. I've got it to work, but I don't understand how it's working.
My understanding is that with MVC5, when you request a page from an action method of a controller, it will look inside the 'Views' folder for a html file with the same name as the action method and return it.
However, following this guide for setting up angular 2 in Visual Studio: https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html
I now have an 'app' folder that's sibling to the 'Views' folder. and an index.html that's in the root of the project folder. So how is it when I launch the app, the index.html from the project root is returned, and not the 'index.html' from the 'Views'->'Home' folder?
Also, this current setup seems a bit messy. Is there a way for me to move all the angular related stuff into one folder called 'client' for example?

Deploying multiple ASP.NET MVC application in a single Virtual directory

Normally an ASP.NET MVC application can be deployed by placing the application folder in the virtual Directory.
The application folder contains
bin folder
Scripts Folder(If needed)
Views folder
Global.asax file
web.config file
But, I want to place the bin folder outside the application folder so that I can deploy more applications in a single application folder. All applications share the bin folder and session also get shared.
What I want to do
..Virtual Directory
..\bin
..\App1Name\App1Contents
..\App2Name\App2Contents
..\App3Name\App3Contents
..web.config
I already achieved this for web application with web forms without Global.asax file. But in MVC application I am unable to shared the bin folder.
How to achieve it?
Where I need to place the Global.asax file?
How the route all the applications with bin folder placed outside the Applications?
Thanks in advance
This is not possible. You were able to achieve this with Web Forms because each individual page is in effect it's own application. However, MVC works differently. Many factors, not the least of which is the routing framework, requires that the web application be secluded. You cannot deploy multiple MVC applications to the same document root. You can deploy a second MVC application to a virtual directory within the first, but be advised that the web.config of the outermost application will affect the inner application as well.
Based on the fact that your applications are sharing common binaries already, you may want to look into using MVC Areas to facilitate a logical separation between applications (but have them all as part of a single application). The following link describes this in more detail: MVC Areas

Nesting Multiple Applications

Is it possible to have separate multiple MVC projects within a single hosting environment?
For example I have one MVC 4 project uploaded to an external hosting environment located in the root folder and I would like to add a sub folder to host the second MVC 4 project. I have successfully published the second MVC4 project to the sub folder but when I try and access the second project I get a 403 Forbidden error or if I try to pass a specific URL I get a 404 The resource cannot be found error.
I have checked the FTP sub folder and it contains all the relevant folders and files, web.config, bin, etc...
For example if I try www.mydomain.com (1st MVC project) and any URL related to that project it works, if I try www.mydomain.com\newmvc\ (2nd MVC project) I get 403 Error or www.mydomain.com\newmvc\Index or www.mydomain.com\newmvc\Home\Index I get 404 error.
Any help would be much appreciated :-)
I've resolved this by adding an Area to the primary MVC project. This article http://msdn.microsoft.com/en-us/library/ee671793(VS.100).aspx was most useful.

JuiceUI implementation on a Virtual Directory in IIS

General Description :
I have installed JuiceUI on a local build of a web form application in asp.net in Visual Studio 2010. What I want to do is take this application and add it to a virtual directory that has been setup for me. I have JuiceUI working on my local version, but it does not load the AJAX (such as the datepicker [i.e. calendar]) on the virtual directory.
Any help to get this loaded onto the virtual directory would be very much appreciated.
Details I know to give at the moment :
This is a web form application. To deploy to the virtual directory, I copy and paste the directory of my code into the directory space on the server. Therefore my bin folders and jquery are loaded on my app folder. I have configured the parent website web.config membership provider so that I can connect and access my app.
So I have had my page working just fine on the virtual directory. I installed JuiceUI on my local build and was now copying it to the website to realize that none of the ajax functionality was working.
I'd say the first step is to verify that the browser is loading the necessary js and css files. Use chrome inspector or firefox+firebug and look for any 404s on the resources. If the scripts and css aren't loading, then you'll need to adjust their location in code to match your setup.

Categories