Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can I have BOTH a virtual directory and an application directory within the same web structure?

I inherited a website that uses one web.config file for all of its pages - which is fine.

I have had to add new pages and have included a separate web.config file in this new folder with the new pages. I had to include a separate web.config file because my new pages weren't "recognizing" the existing web.config file.

I am getting "
Quote:
element 'buildProviders' cannot be defined below the application level.
" errors when I publish my new pages into my new folder. The best solution I have found is to convert the newly created folder to an application via the IIS Manager.

Can I have both virtual and application directories within the same web structure without affecting the pre-existing pages?

I have used VS 2013 to clean, build, and publish my new pages.

I have an .aspx page, and aspx.cs page.

What I have tried:

I want to be sure converting my new folder to an application is the best solution before I implement this solution.
Posted
Comments
Richard Deeming 20-Jul-16 14:13pm    
Yes, you can convert the folder an application without affecting the rest of the site.

But it would probably be better to resolve the problem of your new pages not "recognizing" the existing config file.
Member 10379103 20-Jul-16 14:35pm    
It looks like the issue with my new pages not recognizing the existing web.config file is because I did not publish the entire solution - only the new pages that I created...at least, that is according to the previous developer. The previous developer always published the entire solution. The entire site uses one web.config file. I also noticed that after the clean, compile, and build, my .aspx.cs and aspx.designer.cs pages are still visible in the solution - it doesn't look like they actually compiled (?). I am researching this issue before I convert the new folder.
Member 10379103 20-Jul-16 15:17pm    
I just re-built, re-compiled, and republished my new pages. I got the same web.config error: Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customerrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customerrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customerrors mode="Off">



When I create a new web.config in the folder with my new files and set the customErrors mode to "Off" so I can see what line is erroring, it stops on the first line - which is what successfully compiled:
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 type 'RescueDogs.NewBreeds.PlacementStatusReport'.

Source Error:


Line 1: <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="PlacementStatusReport.aspx.cs" Inherits="RescueDogs.NewBreeds.PlacementStatusReport." %>
Line 2: <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
Line 3: <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">


Source File: /NewBreeds/PlacementStatusReport.aspx Line: 1


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1031

The first line is the same in all of the previous files - except for the name of the new report.

I am open to any suggestions on how I can resolve this issue...short of creating a new web.config file for my new files and then converting that new file to an application.



Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customerrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customerrors mode="RemoteOnly" defaultredirect="mycustompage.htm">

Richard Deeming 21-Jul-16 6:47am    
Check the code-behind file PlacementStatusReport.aspx.cs - does the namespace and class name match the Inherits attribute?

Also, you seem to have a rogue period at the end of the class name. Is that in your code, or a typo in your comment?
Member 10379103 21-Jul-16 7:16am    
Yes, the namespace and class matched the Inherits attribute. I copied and pasted to be sure. The rogue period is a typo. What resolved my error was removing the Inherits from the .aspx. When I published the .aspx from VS 2013, the .cs and .designer.cs also published. In the pre-existing pages the other developer wrote, only the .aspx appear in the folders.

I'm thinking my build didn't actually compile the code behind into the library and that's why I got the error...the .aspx page didn't see the .cs in the .dll because it wasn't there to be inherited.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900