I've got a big problem with create a folder in a WCF application running under Asp.net
Do following steps !
Create Asp.net MVC project -> Done
Create a WCF service inside asp.net MVC project ->Done
Inside WCF, create a method (i just want to create a folder inside this method) named CreateFolder() ->Done - it's works
This is code inside method created :
var path = HttpContext.Current.Server.MapPath("~/UserData");
Directory.CreateDirectory(path);
Well, it's doesn't work !
Now, try again with another code !
var path = HostingEnvironment.MapPath("~/YourDirectory");
Directory.CreateDirectory(path);
Again, it' doesn't work too.
PS: it's only works on Local machine PC.
When i published asp.net Website and upload to my hosting, everything good except above method(create folder)
Any idea ?
PPS: I just want to create Folder for user registered !
Test it with a direct path address, like "d:/UserData" instead of "~/UserData".
Related
I want to add a service reference to a wsdl web service in my ASP.NET website. In Visual Studio I right clicked the project and then Add service reference. It then created the *App_WebReferences* folder with some files in it and it added some new things to my web.config.
After I moved the changes to my test server by copying the new file, the App_WebReferences folder and the changed web.config, the server tells me that I'm missing a reference for the web service. I thought it should be in either web.config or that ASP.NET should find it in the App_WebReferences folder.
I've missed something obvious but I can't figure out what. What have I missed and what do I do to get my web service reference to work on my test server?
It's working really well on my local machine.
Was this working fine locally? You need to make sure you import the service to any classes that may be using it (or Using if you are doing this in C#). Also, is the service you imported from a project that is on your pc? IF so, you will need publish that as well to the test server.
I am new to Visual Studio and ASP.NET. I have a MyClass.cs file under App_Code directory, but could not able to run the function in the class file. Keep getting this error:
The name 'MyClass' does not exist in the current context
I know that code works fine since I posted the codes and others confirmed it works, but I am still receiving the error above.
I read alot more threads on the NET and somes indicated that problem is using Web Application Project instead of Web Site project, which the class file would not compile. I am not sure if I've created it under Application Project we Web Site project.
How can I tell that my site is running under Web Application Project or Web Site Project? and How can I change it to Web Site Project so my class can be recognized.
Thanks in advance,
I have an ASMX Web Service that has its code entirely in a code-behind file, so that the entire contents of the .asmx file is:
<%# WebService Language="C#" CodeBehind="~/App_Code/AddressValidation.cs" Class="AddressValidation" %>
On my test machine (Windows XP with IIS 5), I set up a virtual directory just for this ASP.NET 2.0 solution and everything works great. All my code is separated nicely and it just works.
However, when we deployed this solution to our Windows Server 2003 development environment, we noticed that the code only compiled when all of the code was dropped directly into the .asmx file, meaning that the solution didn't work with code-behind. We can't figure out why this is happening.
One thing that's different about our setup in our development environment is that instead of creating a separate virual directory just for this solution, we dropped it into an existing directory that runs a classic ASP application. So here we have a folder with an ASP.NET 2.0 application within a directory that contains a classic ASP application. Granted, everything in the ASP.NET 2.0 application works if all of the code is within the .asmx file and not in code-behind, but we'd really like to know why it's not recognizing the code-behind files and compiling it correctly.
As others have mentioned, it's probably a better practice to build the solution as a "Web Application Project." This way your code will be precompiled to run on the server.
The following solution worked for us: In IIS, navigate to the folder in your website that contains your solution. Right click on the folder and choose Properties. In the Directory tab, under Application Settings, click Create to make the folder into an application (I believe this can also be accomplished simply by making the folder a Virtual Directory). Then, make sure your ASP.NET configuration is set to use ASP.NET Version 2.0. The problem we had was that the larger directory was running under ASP.NET 1.0, so we had to go through this step to have this directory use ASP.NET 2.0.
You may have a difference between a Web Site "project" and a Web Application project. In a web site project, all of the files are compiled dynamically. In a web application project, you have to build the code first.
You should be using Web Application Projects for web services. Use File->New Project and choose the appropriate project type. Then build your project and finally use the Publish command to deploy to IIS.
I'm not sure I can explain why its not working however placing Code behind files in the App_Code folder seems like a dodgy thing to do. App_Code files will get compiled into a single assembly. Hence the code in your code behind will end up in this assembly even though its not intended to.
I would first create a AddressValidation.asmx.cs file in the same folder as the .asmx folder and tweak the CodeBehind attribute of the asmx file. Remove the file from the App_Code folder and place its contents in the new .asmx.cs file.
Check this works in the XP environment then move it the destination server.
i have an project with name called(dbservice layer) which is in path: d:\webservice\DBService. here i have an webservice which connects to DB and returns an object of an class.
once i added an reference here i get an url:http://localhost:2371/Jobs.svc
now i have another project name (UILayer) whic is in path: E:\School\UILayer
i added an service reference here with url as http://localhost:2371/Jobs.svc
but i get an messgae telling service is unable why is that happening.
if both my webserivce layer and ui layer are in same project. then i able to use the webserive in the ui layer. and get the required output
so i wanted to know is there any way we can acesss the webserive from one project to another project
thanks in advance
prince
Publish your web service to an actual location and then add a reference using the actual URL not the one served up by visual studio. What I think is happening is each Visual Studio instance is using a different port so you can't say localhost:2371 for both projects because that is the local port for the instance your running with your original project.
Publish it and then access it via http://localhost/jobs.svc. You should be able to access it via IE directly without running Visual Studio if you have published it correctly.
The main point is, you have the wrong URL.
I have created a web service in a virtual directory using VS 2008. I have tested the service by going to the .asmx page and everything is working fine. So I selected the "Add web reference" option under the solution and typed in the .asmx URL. It found the web service successfully and added the reference to the project. However, when I try to import the service namespace using the same name as the directory under the "App_WebReferences" folder, it doesn't recognize the name and gives me an error if I try to import it. Have I missed any steps in the process?
Update: Try generating the proxy manually using the wsdl tool and adding the proxy class as an existing item to client web application project as mentioned in the link.
Something strange happening with proxy generation in your case from VS. Maybe an access issue.
If it happened fine, you should be able to find the VS generated proxy class under one of the sub-folders of
%windir%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ (for Asp.Net 2.0). Search for file names starting with App_WebReferences*.cs in the temporary folder.
When you added the web service, what is the name of the web reference you gave? Use the same web reference name in your import statement.
In this link, web reference name is com.deepfitness so you can import com.deepfitness namespace in your asp.net app.
To be absolutely certain click view all files in you web project and follow your reference in App_WebReferences down until you get to reference.cs open this and you can see the correct namespace.