IDE says MasterPage not found, but builds/runs fine - asp.net

I am stumped as to why my pages are saying the MasterPage cannot be found, even though the MasterPages are where they are specified. For example:
In default.aspx
<%# Page Title="Welcome" Language="C#" MasterPageFile="~/Master.Master"
AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="My_site.default" %>
In the above line, "~/Master.Master" is underlined in green. Hovering with my mouse shows a balloon that reads File '~/Master.Master' was not found. Master.Master definitely exists in the root folder of my site. The site builds fine and all of my pages DO find ~/Master.Master when ran on either my local PC or when uploaded to my hosting account.
The biggest annoyance is that I can't view my pages in the VS IDE because it says The Master Page file '~/Master.Master' cannot be loaded. Correct the problem in Code view. I see nothing to fix...
I have completely deleted the /obj/Debug and /obj/Development folders, clicked to Clean the entire solution, and done a complete build. Every page that uses a Master Page on my site is telling me this.
After running into some problems with long filename errors (unrelated issue) I moved my solution/project to a folder off of my C:. I named the solution folder C:\My_Site and inside of it there is a project folder called My_Site. The full path to my project files is C:\My_site\My_Site.
If I change MasterPageFile="~/Master.Master" to MasterPageFile="~/My_Site/My_Site/Master.Master" then the IDE stops reporting an error and will allow me to view pages in design mode without a problem - although the site will not build this way. The compiler reports problems that the Master Pages cannot be found.
I read a post here on SO - Error: "The file '/MasterPages/MainMaster.master' does not exist." (Yes, this file does exist!) but my files are not located in a virtual folder. I use IIS Express and so am pretty limited with configuring it. I am uneasy about right-clicking my project and converting it to anything. I'm not sure what the effect of that would be.
Anyone have an idea what's possibly happening and how I might resolve this?

Related

Organizing ASP.NET Web Application Project

How do I update references to user controls after putting ascx and aspx files into different folders?
I'm not used to working with ASP.NET Web Forms projects, but I inherited this one. When I first received this Project, every file was directly under the root; no folders whatsoever. I've started putting files into folders and updating the paths.
When I try to load a user control, however, I get this error:
Cannot use a leading .. to exit above the top directory.
My user control is located at:
myProject\controls\Widget.asxc
My page is located at:
myProject\Pages\Activity\AST_Page.aspx
Markup from AST_Page.aspx:
<%# Register TagPrefix="tf" TagName="Cost" Src="..\..\controls\Widget.ascx" %>
My understanding is:
When a user navigates to AST_Page.aspx, the current path is myProject\Pages\Activity\.
Starting a path with ..\..\ should put me at myProject\.
Therefore, ..\..\controls\Widget.ascx actually points to myProject\controls\Widget.asxc.
My Project has access to my myProject\.
If I change ..\..\controls\Widget.ascx to ..\controls\Widget.ascx, I get a different error about not finding the file, which is expected as Widget.ascx is not under myProject\Pages\controls\.
There was a second issue on the page. I had "~/../../" in a src attribute; likely due to an aggressive find and replace.

# Registration doesn't resolve controls for "DotNetNuke.Web.UI.WebControls"

Probably this something very simple, but I can't find what I'm doing wrong.
I want to use DNNTreeView in DNN 7.0.6 dev site. This instruction page almost get me there. The code behind resolves the controls, but the .ascx doesn't and gives me the following warning
Warning 102 Element ‘DnnTreeView’ is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing
the page looks like:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="View.ascx.cs" Inherits="MySpace.Modules.MyModule.View" %>
<%# Register TagPrefix="dnn" Namespace="DotNetNuke.Web.UI.WebControls" Assembly="DotNetNuke.Web" %>
<dnn:DnnTreeView runat="server" ID="tvMain">
</dnn:DnnTreeView>
I'm using #ChrisHammond 's templates for the solution.
I have following dll references:
DotNetNuke.dll
DotNetNuke.Web.dll
Telerik.Web.UI.dll
Can you smart guys find what I'm missing?
I've found a possible solution for the "not a known element" warning. I was pulling my heart out looking for it, but I have one that works for me. All you need to do is add a bin folder to your module and put these dll's in the bin folder: DotNetNuke.dll, DotNetNuke.Web.dll, DotNetNuke.WebControls.dll, Telerik.Web.UI.dll. It doesn't matter if they are in the site bin folder, they need to be in the project bin folder, too.
I have a full explanation here
If it is just a warning, I wouldn't worry about it, that is fairly common with DNN module development using the WAP approach. If it works in DNN, then just let it go :D
You might check to make sure that you don't have a virtual directory/application on the DESKTOPMODULES folder in IIS, or on the module's folder itself.

You are attempting to open a precompiled Web site

I have a website developed in asp.net. Files have both aspx pages and codebehind files. When I try to open it in Visual studio 2010, I get this message:
---------------------------
Microsoft Visual Studio
---------------------------
You are attempting to open a precompiled Web site. You can view the site, but changes might cause the Web site to stop functioning. To modify a site, it is recommended that you edit the files in the original Web site, precompile the site, and then publish it again.
Do you wish to continue and open this Web site?
---------------------------
Yes No
How to open this website for editting ?
I know this is WAY late but it might be of use to subsequent readers.
First off, Martuza Kabul is wrong. You only need 2 files, the .aspx/.ascx/.master and the relevant .cs (this means .aspx.cs/.ascx.cs/.master.cs)
What has most likely happened here is that somebody has compiled the site and the DLLs are now lying in the bin folder. (If you are as lucky as i am, they're also in source control..)
Here's what you need to do:
Delete the PrecompiledApp.config file
Delete all the non library .dll files in your bin folder (mine were WebApp_122141Xas or something like that, these are compiled codebehind files.)
Look at the first line of your .aspx / .ascx pages - In that control tag - in there is an "inherits" attribute... you will see it has 2 values, delete the 2nd one.
In that same control tag, notice that the Codefile attribute is missing. Add it and point it to the correct codebehind file.
That should be it. Hope this helps somebody.
You have to have CS file to edit the website. I assume that you are trying to open a website which was published earlier using precompiled option.
Pls post type of files in your website for further information.

Does code in aspx page get compiled in a web application?

Let me just start by saying, if anyone knows of a good article that talks about this subject, please point me towards it.
Does code in an .aspx page (in between <% %> tags) get compiled in a web application or is it treated like markup where you can just change it without recompiling the solution? Does compiling only compile the code behind code in the .cs and designer.cs files ?
If you're developing in a 'Web Application Project' (as opposed to 'Web site') then any change to class (.cs), code-behind file (.aspx.cs), designer files, etc (basically anything that isn't markup or static files like .htm) would require a rebuild in Visual Studio.
All code within a .aspx file, in or out of code blocks (<%%>) gets compiled.
Changing an .aspx file will cause IIS to recompile it on the next request.
See MSDN - ASP.NET Dynamic Compilation.
Update (following comment):
As for development work - pretty much the same happens when you use the dev web server to view the page. You do not have to recompile the solution/project, but the page will get recompiled dynamically.

How to tell what page a dll refers to in precompiled ASP.NET site

I'm using a pre-compiled ASP.NET 2.0 site (i.e., copied to the server using the "Build->Publish Web Site" feature in Visual Studio 2005). I catch and log all errors which are usually quite detailed, but lately I've been getting the following error with no other information:
Could not load the assembly
'App-Web-rp2eml-j'. Make sure that it
is compiled before accessing the page.
Now, that 'App-Web-rp2eml-j' file should be a dll in my bin folder which was created for the pre-compiled site. My main question is, how do I tell what aspx page is looking for that dll? I've tried re-publishing the site, and even completely wiping out the site and re-publishing, but the problem does not go away.
When Googling the problem, most answers about this error message center around making sure IIS is set up to use ASP.NET 2.0 instead of 1.1. This is not my problem.
NOTE 1: The site all seems to work, but obviously there is (at least) one page that is broken which I cannot find.
NOTE 2: The file name above should have underscores instead of dashes, but SO's markup is changing the text between the underscores to italics.
Does the mentioned dll exist in your bin directory? You italicized that portion so I suspect that it doesn't. That could mean that the error is referring to a dll in the Temporary files folder.
This problem can occur if one or more of the dlls in the ASP.NET Temporary files folder are corrupted. Sometimes ASP.NET does not refresh files here if there are no changes in the dll residing in the virtual directory. It happens every once in a while on my server.
My solution is as follows:
Stop IIS services on the server for a minute or so.
Navigate to the ASP.NET Temporary files folder (usually located at "%windir%\Microsoft.NET\Framework\\Temporary ASP.NET Files\MyApplicationName") and clear all files within the folder.
Publish and upload my site to the configured virtual directory.
Restart IIS and other services.
This simple 4-step process has worked very well for me in the past and may be worth a try for you.
To answer your basic question, however, there are two ways to "reverse engineer" a dll:
Load it up in ILDASM and check the contained classes.
Use Reflector to save all the class files contained within the dll to a folder.
However, I doubt if this will solve your problem because each dll could contain many class files and you would not have a clue as to "which ASPX page is looking for that dll".
Maybe you can catch more detailed information on the error with the Global.asax event Application_OnError, so you can watch the stack Trace.

Resources