I've got a C# 3.5 web service that works fine when its accessed at http://domain/foo/bar/WS.asmx
The /foo/bar part could change in the future so I want to give people a more stable URL that I could update without requiring any changes from them. I created a site in IIS and set it's Home Directory to where WS.asmx is. Now when I try to access it from http://domain2/WS.asmx, I get:
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 create
type 'Namespace.WS'.
Source Error: Line 1: <%# WebService
Language="C#" CodeBehind="WS.asmx.cs"
Class="Namespace.WS" %>
The assemblies in both cases are at http://domain/bin but when I come from domain2 it doesn't seem to know where to find the \bin that is 3 folders up in the file system.
The namespace/classes are more descriptive than that, I just made them basic for the purposes of this question.
Sorry, AFAIK you can't pull DLLs from explicit file paths outside the root of your website. You generally have two choices:
1) use the /bin directory of the current app (make a copy of the other app's /bin)
2) put the DLL into the Global Assembly Cache (GAC)
BTW, this has been asked in a few other spots on SO, like here.
One thing you could do, if your /bin DLLs are only used inside /foo/bar/, is to convert into an IIS application, and then move the DLLs into a new /foo/bar/bin directory. Then you'd only have one copy of the DLL's to manage.
Related
I was trying to run a .cshtml file but it gave an error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /index.cshtml
So I searched for the solution and found that I had to edit the web.config file which is in the root directory(here it is My Site), but there is no file like that there there is only an index.cshtml which I had created.
I searched even the IIS and the IIS Express folders in Programs Files\ but there was no file like that?
If you are using WebMatrix, maybe your mistake was the starting point choice.
If you want to create a new Web Pages site you must start from a template in the Template Gallery of WebMatrix. Pay attention that the Empty Site template differs from the Empty Site option outside the Template Gallery because the first holds the files (binaries, packages and the web.config too) that are needed.
As the server error suggests, .cshtml files are not served, the reason for this is because they are server-side files that make up your application, they are just one piece of a much bigger picture.
If you launched your web application in debug mode and the URL in the browser was something like http://localhost:2932/Views/Home/Index.cshtml, just drop the /Views/Home/Index.cshtml part of the URL.
I have currently moved my asp.net 4.0 web application onto IIS7 (windows 2008 server). I used a test folder to hold files from a directory on the localhost machine, however; when I moved the aspx file over and changed the code(on the server), the application keeps throwing this error
Could not find a part of the path 'C:\Users\***\Desktop\TestFolder\'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\****\Desktop\TestFolder\'.
I only have two functions that deal with directories and neither function points to that test directory anymore.
private int checkForFileNumbers()
{
string url = "c:/***/realfolder";
DirectoryInfo directory = new DirectoryInfo(url);
return directory.GetFiles().Length;
}
private void checkForFiles()
{
string url = "c:/***/realfolder";
DirectoryInfo dir = new DirectoryInfo(url);
foreach (FileInfo files in dir.GetFiles())
{
FileDropDownList.Items.Add(files.Name);
}
}
I have tried commenting everything in this aspx file out, only to find that this problem still occurs. I performed the issrestart from the cmd line and nothing changed. Any help would be appreciated.
This is a deployment problem. Your error message is clearly out of sync with your current code. The actual code that is being run from IIS must be coming from an out-of-date binary. As a starting point, I would delete all DLLs in your bin directory on the server and redeploy fresh DLLs. The may also require you to refresh your aspx files depending on what kind of project type you're using.
Once you get this sorted out, I would take another look at how you are deploying updates to your site. Visual Studio and IIS 7 offer some neat deployment options if you want to go that way. Also, you could deploy via Git or SVN. But deployment by manual replacing single files is going to lead you to the type of trouble you are currently experiencing.
If realFolder directory exists under root of your web-app or itself is root then use Server.MapPath method to get real path of virtual folder.
For instance,
String rootPath=Server.MapPath("~"); // It will return real path of current web-app's root.
//OR - In case if want use Server property from separate code file.
String rootPath=HttpContext.Current.Server.MapPath("~/testFolder");
Since you're not referencing the path in your code, it's probably either in one of your config files, HttpModules, Global.asax, or perhaps a DLL.
What other components are you using?
Before moving it to a server, have you tried running the site under IIS on your local machine? Maybe attach a debugger and see where the error is thrown?
Oh, FWIW, the IIS AppPool identity will need to have read permission for your C:/***/whatever folder.
I have an asp.net solution containing more than 1 projects which are inter-related and each project have different configurations in web.config file. The whole solution is kept in a folder, lets say 'X'. I want to run the solution in iis. For that, I have created a virtual path in iis of 'X', converted the folder 'X' to an application, and created a web.config file in the root folder that is 'X'.
When I am viewing one of the project' default page in browser, it shows an error of
Parser Error Message: Could not load type 'app1.SiteMaster'
I have already compiled the solution.
Please help... Am i missing some settings...
It sounds like the application can't find the master page. Assuming that your projects share the same master page, you probably need to update the path to the master page to the relative path from the root.
Have a WCF service in a "Services" directory in my asp.net web app. In
/Services/MyService.svc
/Services/MyService.svc.cs
Everything works when copying my source code to the virtual directory. We were really hoping to precompile the code for various reasons, but when we do the service breaks. I am assuming becuase now the ".cs" file is precompiled and there no longer is a "MyService.svc.cs" in the "/Services" directory.
The Error
Error: Cannot obtain Metadata from http://myurl.com/services/MyService.svc
My .svc mark up is the standard:
<%# ServiceHost Language="C#" Debug="true" Service="MyNamespace.MyService" CodeBehind="MyNamespace.MyService.svc.cs" %>
Is there something I am doin wrong, or that I can change on the WCF client/service to allow for ASP.net precomilation?
Assuming you're talking about a precompiled site, take a look at this blog post. Basically the site has to be updatable.
One of my coworkers found this and it works. It is not the best solution, but it works.
http://social.msdn.microsoft.com/forums/en-US/wcf/thread/8c897f8e-2143-450e-a9f4-97d1f8702da7/
EDIT:
Even better solution...We use a deployment project and it seems that the project specifies the project name as the virtual directory path unless otherwise specified. We opened up our deployment project file and updated the below node to the appropriate virtual directory name:
<SourceWebPhysicalPath>..\MyVirtualDirectory</SourceWebPhysicalPath>
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.