I have a Visual Studio 2010 project with a Master Page that works fine.
~/Site.Master
In the same project is a Folder with another directory structure that needs to use another Master Page.
/xr
Within this folder, I have included the Master Page for those files.
/xr/XR.Master
My Default.aspx file attempts to access this Master Page using the following include:
<%# Page Title="XR Project" Language="C#" MasterPageFile="~/xr/XR.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test1.Default" %>
Debugging on my machine in localhost works fine, but whenever I deploy it and try to navigate to the Default page in the xr folder, I get
Parser Error Message: The file '/xr/xr/XR.Master' does not exist.
However, the Source Error returns Line 1 as I have shown above.
Here is what I tried:
I moved the XR.Master page into the root folder and changed all of the files in the xr folder to reference the XR Master Page using the following include:
I debugged and tested the code on my machine using localhost, and it worked fine.
I pushed it out to the remote website and got the new error:
Parser Error Message: The file '/xr/~/XR.Master' does not exist.
What am I doing wrong?
EDIT: I do not like posting a link to the page, but I will for a short time until this is resolved:
Projects
From there, you will see everything works well enough except for the link to XR1200.
Here's the best advice I can give ya without knowing too much about your project structure.
I'm hoping you are using VS2010 so that things will look the same for you as on my machine.
One easy way to get the path of your master page all figured out is to add a test web page from masterfile, the path will be preset for you and you can use that in your existing pages.
Here is my blogs project structure.
Right click the folder where you want to add the test page and click add new file.
Add a new web form using Master Page. This is just for testing.
Now locate your Masterpage and select it.
From here just find your newly added content page in your solution structure and check the code files for the path to your masterpage.
Once you've verified that your path is correct, if it still bombs once you publish it then you've got either an issue where not all of your projects are building properly, or you're files aren't being uploaded properly and that is going to end up being something that you may just have to find on your own. I still suggest blowing away anything in your pub folder on your server and trying a clean publish.
Hope this helps!
my guess is that the iis setup is different on the different machines. typically, you see something like this when you have one machine set up with the site itself as a website and another machine set up with the site itself as an application within a website (like the Default Website). it looks like you have addressed this possibility by using the ~ in the path, but perhaps the iis on which you are deploying does not have the site directory itself set up as either a website or an application, but is merely a subdirectory of a site. in that case, the ~ would refer to the website directory (perhaps named xr?) and the site is in a subdirectory of that named xr. if this is the case, the solution is probably to set up iis such that you have the application directory configured as an application on the server to which you are deploying.
Related
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.
We are working on a website project which contains around 1130 pages. After compilation, all the .aspx.cs files are converted into AppCode DLLs that has random names.
Whenever there are any changes in single .aspx.cs file[like a hotfix], we have to recompile and deploy the entire project on the application host.
We want to update only those files that have been changed and not the entire package.
One of a solution we are aware is that, converting Website to Web application; but we cannot implement that change at this stage of the project.
Is there any other way to find an efficient solution for this?
Yup. Talking in Visual Studio 2010:
While publishing the website, Select the option: 'Use Fixed naming and single page assemblies', Also select 'Allow this precompiled site to be updateable'.
After website is published. Go to the published folder. Open any aspx page (not the dll or .cs).. Note the dll name in page attribute under inherits attribute. Than using ftp or any other way to upload, copy or upload tht dll under bin to your website.
Also, you can create a doc or txt file to list all Dll names with respective paths to your file to easily know which dll to upload next time if there is any change.
Hope it helps.
We are publishing our website using VS10
1) While publishing the website Localy, only aspx files are grouped together in the published folder and that web is working fine in the local IIS server.
2)though .cs files are not in the published folder all the events are working well in Local iis server
3)what I am doing..... I am coping that published web folder and uploaded it to the web server.
4)but now it showing an error for every event I calling????
5) how can I tackle this problem??
6) For security reason I don't want to upload my code behind files to web server?? I want to hide my programing logic how can I do this ????
7) when I am uploading my web with both the .cs and aspx files it working well but I don't want to do this??
You need to publish your website it will generate dll put that instead of putting .cs files. This codeproject article explains how to do it.
You do not need to copy all of the files. You only need to upload the .ASPX file and the Bin folder which will contain the compiled logic in a DLL named YourProject.DLL and also any other references that are required. The .CS files containing your actual code are not required on the server as they have been compiled into the DLL.
With JavaScript you cannot hide this from the user because it is needed on the client-side. However, you should save all of your JavaScript into a .JS file and include on the page. At least it makes it less obvious to someone viewing the source of your page.
Publishing your web site will do the job.
Please read How to: Publish Web Sites (Visual Studio)
and
ASP.NET Web Site Project Deployment Overview
The site works fine when I'm running it locally, I published it and hosted to a hosting space hired by my company via SMART FTP.There is a folder with my company's name eg. 'MyCompany'. It has sub folders such as App Data, App Code, Bin, Httpdocs,Httpsdocs...etc. I transferred my published project'UtilityServices' to Httpdocs. Then i enter www.MyCompany.net/UtilityServices/Customer_Login.aspx i got the following error.
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load the assembly 'App_Web_ah9y-lsc'. Make sure that it is compiled before accessing the page.
Source Error:
Line 1: <%# page language="C#" autoeventwireup="true" inherits="Customer_Login, App_Web_ah9y-lsc" %>
Line 2: <%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
Line 3:
Source File: /UtilityServices/Customer_Login.aspx Line: 1
Httpdocs has a bin folder and a webconfig, the hosted UtilityServices has a bin and webconfig. Is this the reason for this error.
I am using VS2008 C# 3.5 Framework.
Well, it is an old question and still many search for a relevant answer to this problem.
You need to change the site to an application in the IIS.
Just open the IIS manager and choose the site which has been compiled. Right click the site and choose "Convert to Application". No need to restart the IIS, but there is no harm if you do that. This will solve the problem.
I've had similar problems when transferring files to a web server - what I presume to be happening is that files somehow get corrupted in transfer, and you get weird assembly names.
What worked for me is, if I could find out what files broke the build on server (if it worked before I uploaded a batch, then I got compile error of this type), I would make minor changes (press space and backspace) to force a save on them, and reupload those files, and in turn that would make server recompile them again and the error would be gone.
Hope this works for you :)
If the app you have in /UtilityServices/ has it's own App_Code folder, etc, then the directory needs to be configured as an Application in IIS. See this link for instructions on how to do this.
If you cannot configure the webserver, try placing the files in your App_Code, bin, etc folders in there corresponding folders at the root of the site.
I'm currently working on an ASP.NET 4.0 site using a project-less solution.
By default the global.asax does not have a code-behind file, but after I changed it to
<%# Application Language="C#" CodeBehind="Global.asax.cs" Inherits="MyNamespace.Global" %>
And created an empty Global.asax.cs with the same namespace / class name I'm getting this error at compile time
Error 1 Could not load type 'MyNamespace.Global'. C:\Projects\RiskOptix\Code\RiskOptix.WebApplication\RiskOptix.WebApp\Global.asax 1
I've already tried cleaning out my entire bin folder but to no avail - this is extremely infuriating.
This question has already been asked. Check out this answer. Web site projects work differently from web application projects. Website type projects do not have CodeBehind files instead have CodeFile.
<%# Application CodeFile="Global.asax.cs" Inherits="MyNamespace.Global" Language="C#" %>
CodeBehind = Needs to be compiled ( asp.net 1.1 model) and compiled binary is placed in the bin folder of the website. You need to do a compile in visual studio before you deploy. Good model when you do not want the source code to be viewable as plain text ... for example when delivering to a customer who you not have obligation to provide code.
CodeFile = You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsfot.NET[.NET version]\Temporary ASP.NET Files.
I was not able to run my MVC Web application. It was giving Could not load type <application namespace.Classname> error in Global.asax
I went to Project Properties and set the build>output folder to bin/ which was bin/Debug. Ran it once. It ran fine. And then again set the output folder to bin/Debug. Working fine now.
just to add my 2 cents with a WTF moment, My version of this error was caused by the Global.asax.cs not being included in the Visual Studio Project.
Right clicked on the .cs file, include in project and voila...
HTH
Dave
Yet another way to get this into this problem...
I had my web app open in VS2010, and IIS Express could run it just fine. Later, I opened the same web app, but in a newer branch with VS2012, and the virtual dirs in IIS Express auto-magically updated themselves to the physical dirs for the VS2012 project, without warning. So when I hit F5 to run my web app in VS2010 where I'm debugging, then I got the "could not load type or namespace" error in the global.asax file on one Import Namespace line. Closing both VS instances and reopening just the VS2010 version fixed the problem.