404 error for files from new project - c#

I have a solution with several projects. One of the projects is startUp. It references to other projects are registered in the reference. I added a new project Adkplatform.mrp.web (right click to add a new project in visual studio).
I want to display a test page in the browser.
For the test.aspx page I get the error:
Server error in the application '/'. We could not find this resource. Description: http 404. probably, the resource (or one of its dependencies) is deleted, received a different name or temporarily unavailable. Review the following url and verify that it is entered correctly.
For the test.html page I get the error:*
*Detailed Error Information:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://localhost:3333/test.html
Physical Path D:\WORK\Projects\Test\Software\.Net\Test\test.html
Logon Method Cookies*
I understand it, the search for files in the startUp project.
The test files have Build Action: Embedded Resource
What did I forget to do? In advance, thank.

Sorry, the problem is in our local snippet. It is necessary for the display to call a method c# HostingEnvironment.RegisterVirtualPathProvider for each assembly. For a new project (and new assembly), it not was done.

Related

Add .cs file to ASP Web Site project

I am working on an ASP.NET website and as part of the website I created a file called Global.cs which is used to hold all my helper classes. However, unfortunately, I am constantly getting errors saying there has been a problem while compiling this file. All the classes inside the file are included in single namespace - "Global".
When using it 'inline' eg. Global.SomeStaticClass.Method() :
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Global' does not exist in the current context
When using "using Global;" directive:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Global' could not be found (are you missing a using directive or an assembly reference?)
As suggested in many posts, I tried including the class in App_Code folder of my project and the namespace, "Global", is detected by the Visual Studio (no errors when adding "using Global;" directive, or when using it inline "Global.Class.Method()". However, it still fails whenever I try to access the page in the browser.
I could not find a simple solution to my problem and decided that the easiest and the most time efficient solution will be to convert my Website project to a Web Application project. You can read how to convert your Website to a Web Application at: https://blogs.msdn.microsoft.com/webdev/2009/10/29/converting-a-web-site-project-to-a-web-application-project/
With the project converted to a Web App I was able to attach my class files after compiling them to a DLL library, as it did not accept any uncompiled files inside App_Code folder by throwing an exception.
The directory '/website/App_Code/' is not allowed because the application is precompiled.
If you encounter the same issue, you can learn how to compile C# files using Developer Command Prompt here: https://msdn.microsoft.com/en-us/library/78f4aasd.aspx

Resource not found in .net

I start debugging the code and getting the following Error.
What could be the cause of following Error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies)
could have been removed, had its name changed, or is temporarily unavailable.
Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Main.aspx
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3655;
ASP.NET Version:2.0.50727.3658
Looks like you do not have Main.aspx or it is in one of the sub directories. Please check the location for the web form.
The application can not find the page /Main.aspx.
It could be that you're looking for it in the wrong location. Ensure it's located in the correct folder structure that you're trying to access.

File not found exception for my MyWebservice.XmlSerializers when using PrincipalSearcher.FindAll()

I have a web service added by service reference (called "MyServiceReferences") in my ASP .NET MVC 4 solution. Also I have an Active Directory service in another project in the same solution. I am trying to display user name (First name and Last name) in my web page using active directory users information. The problem is when I call
PrincipalSearcher.FindAll(), it works sometimes. The exception I am getting is
Could not load file or assembly 'MyServiceReferences.XmlSerializers'
or one of its dependencies. The system cannot find the file specified.
In my project build setting I have tried to set Generate serialization assembly "On". But it did not solve my problem.
Following command from visual studio command line solves the problem
Sgen.exe (locationOfTheDllFile)\MyServiceReferences.dll
But there is another following error occurs rarely (when attempting to load the page very very often)
[System.AppDomainUnloadedException] = {"Attempted to access an unloaded appdomain. (Exception from HRESULT: 0x80131014)"}

MachineToApplication beyond application level - What does this error means?

What should i do when this error prompt my screen
In VS2008 Express Edition
C:\Users\ami\Desktop\MyAddressBookasd\MyAddressBook\UpdateTheRecord.aspx: ASP.NET runtime error: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
In Web Browser
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as Definition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 36: ASP.NET to identify an incoming user.
Line 37: -->
Line 38:
Line 39: section enables configuration
It seems you have not configured the virtual directory for your website as an application in IIS. If you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and may get the above error.
please visit this link to solve it.
allowDefinition='MachineToApplication' beyond application level" in asp.net
There can be one of many possible reasons for this
You may have added a backup folder inside the main folder. If yes, Remove it.
Make sure that you have opened the correct root folder, in case you are running the project with Visual Studio
Make sure that you don't have any copy of web.config files kept in the project.
Hopefully it helps.
In case you are still experiencing the same problem, let me know :)
Convert to application your virtual/pshysicial directory in IIS Web sites. When convert to appication, resolve your error.

Does Microsoft.ServiceModel.Web only work in the GAC?

I created my first WCF RESTful service with just one GetData, and it works perfectly in localhost, but when I add it to a hosting environment, I get:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'ServiceModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Does this mean that I need to place the DLL file in the GAC to this work? Shouldn't it work in the BIN folder of my service?
Here is how my service folder looks like:
Service.svc
Service.svc.cs
web.config
BIN
Microsoft.ServiceModel.Web.dll
Microsoft.ServiceModel.Web.pdb
MyService.dll
MyService.pdb
PROPERTIES
AssemblyInfo.cs
What can I do in order to make this work?
I had the same problem when I first tried to create a virtual directory directly in IIS 7.5, prior to publishing my RESTful web service to this folder.
The solution for me was to use Visual Studio 2008 (Project Properties / Web tab / "Use IIS Server") to choose the folder, and then the "Create Virtual Directory" button on the same tab to create the virtual directory. Everything then worked OK.

Categories