i have an application wherein i am using a web-service. Now the ip address of the machine where this web-service was residing has changed.
i try to update the web reference in my application and it is still trying to access the web-service from the old location. How do i change this to the new location.
I have already updated the new location in my web.config file.
Please help!!
Thank you.
Right click the service, Choose configure and change the address.
If you're getting an unspecified error you could always remove the existing reference (which will break the build, so don't check anything in), then add the new one. Build and test to make sure it works and then check it in to source control.
Related
I am developing an application in asp.net, vs2015 using c# and the development environment is a Win10Pro machine. I can use any of the various methods to obtain the working directory and see if a particular file exists on the dev pc, but not on the Web Server. I have tried the methods laid out on:
Get current application physical path within Application_Start
All work on the Dev PC, but when used on the Web Server it will not return the working directory. The Server is a 2016 Data server using IIS10. The issue is that the web site I am putting together work fine, except to display GrapeCity ActiveReports reports AR15. The web page containing their web viewer opens just fine and is looking for a report file (MyReport.rdlx). The global.aspx file is pointing to the root directory but when the web viewer opens up, it says File Not Found. I have absolutely no idea and tech support is not sure. Is this an IIS issue that is preventing the code to locate and verify the file is there? Any direction would be much appreciated. This has been very frustrating and time consuming.
AppDomain.CurrentDomain.BaseDirectory does not work, HttpRuntime.AppDomainAppPath does not as well as all the others. The request comes back blank.
string filename = AppDomain.CurrentDomain.BaseDirectory.ToString() +"SPU01_Dates.rdlx";
if (File.Exists(filename))
{
Response.Write("YES");
}
else
{
Response.Write("NO");
Response.Write("</br");
Response.Write(filename);
}
All this just returns nothing.
Thanks.
Try this code
if (File.Exists(Server.MapPath(filename)))
Check if a file exists on the server
In my test, it returned YES and worked well. Did you put "SPU01_Dates.rdlx" file in root folder?
In the development environment, it returned YES, and when I deployed it to IIS, it returned NO. I found that during the deployment process, the rdlx file was not deployed with the project, so I recreated one in the deployed folder, and it returned YES.
The test proves that AppDomain.CurrentDomain.BaseDirectory is the most accurate way to get the file path. When you test this code in IIS, does it return NO or empty? Returning empty means that this piece of code has not been executed.
I have a C# VSTO Word AddIn from which I am successfully making WCF service calls. I am now trying to dynamically replace the config file (MyAddin.dll.config in my AddIn's base directory) from within the AddIn so I can redirect to other endpoints. Once I make the file change, I am using this code to refresh:
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationManager.RefreshSection("appSettings");
ConfigurationManager.RefreshSection("system.serviceModel/behaviors");
ConfigurationManager.RefreshSection("system.serviceModel/bindings");
ConfigurationManager.RefreshSection("system.serviceModel/client");
ConfigurationManager.RefreshSection("system.serviceModel/services");
I do not have any WCF clients open when I do this. After this refresh, when I immediately create a new client
var adminProxy = new CorrespondenceAdminClient();
mcRibbon.serviceHostUri = adminProxy.Endpoint.Address.Uri.ToString();
it appears to have picked up the new information, but when I call a service method, sometimes the call is directed to the correct endpoint and sometimes it is not. When I subsequently create a client and call a service from another part of my AddIn code, again it might or might not get to the expected endpoint. Sometimes the immediate call works but the subsequent call does not.
Is this information cached somewhere? Can I clear it?
I have tried running this from within and outside of the Visual Studio (Premium 2012) debugger and this does not make a difference.
It does get cached, you can try adding "|vstolocal" in registry https://msdn.microsoft.com/en-us/library/bb386106.aspx
I am following the link to save text to image from the following link:
How to generate an image from text on fly at runtime . Taken the code from the accepted answer .
It is working fine in local machine.
The same program is promoted to a build server in a remote machine. And the url I am accessing from my local machine to save the text to image.
The output says "Image is saved", but actually the image is not saved in the path saved in web.config of remote server.
I am not even getting any error message to know whats the problem as there is no exception.
I am running out of ideas as in what could be the issue and why the image is not getting saved. Any suggestions?
Here are some things you can do:
Make sure the folder where you are writing to foresees modify rights to the IIS Apppool identity of the application. You'll need to add it by searching for it in full instead of just the identity, so
IIS APPPOOL\YourAppsIdentity
(note the space between IIS and APPPOOL) and be sure to set the search location to the server machine, not to the domain, which is what it would default to if the machine is joined into one (otherwise the name won't resolve).
In your application's Web.config file you could also set <customErrors mode="Off"> (in the <system.web> section) during development so you get some more verbose error descriptions in the browser window if or when exceptions do bubble up. They can help you on your way to figure out what's going wrong. Don't forget to remove the entry from the Web.config file again once the application goes into production or set the value to "On" if you do, in fact, use custom errors.
You can make this code a little more robust by doing some access control checks on the directory before attempting a write operation. this can help you on your way.
Hope this helps.
I'm trying to create a windows service and I need it to be able to write to the event logs. I've added an EventLog component to my Service project, and set the Log property to be ccs_wscln_log and the Source property to be ccs_wscln (same name as the service).
I have also created and installer for this project. My problem is that whenever I install the service, it creates the ccs_wscln registry key under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application
when it SHOULD be
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\ccs_wscln_log.
The problem with this is that when I try to launch the service, I get an error that says
"The source 'ccs_wscln' is not registered in log 'ccs_wscln_log'. (It is registered in log 'Application'). The source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the source property'.
I've found that if I delete the ccs_wscln registry key under the Application folder, when I start the service it will run and generate the ccs_wscln_log entry under EventLog. So my question is, when I install the application, why is it creating an entry for me automatically under Application, and how do I prevent it from doing this?
I found another post on SO that said I need to restart my computer if I had installed it before under Application, so I tried that but when I reloaded the solution, I couldn't even bring up the designer because it was complaining that the registry entry was missing and it would still install under Application anyways.
I created a tutorial for creating a Windows service from scratch using C#. I address the issue of writing to an application-specific log. See Step 9 here for details.
I think, you would need following in your ServiceInstaller class.
this.Installers.Clear();
Above code needs to be just before you are adding a range of installers.
That is because, EventLogInstaller is added by default. Calling clear will remove it.
Alternatively, you can loop through the installers collection, select the specific type (EventLogInstaller) and assign it required LogName and EventSource name.
I have a file structure set up like this:
ServerRoot
applicationRoot
filePage.aspx
files
chart.png
My application page called filePage.aspx uses another app to custom build charts. I need them saved in files folder. This is how our client's production server is set up and I cannot change this.
I do a _page.Server.MapPath("/files") but it gives me a InvalidOperationException and states Failed to map the path '/files'.
UPDATE:
So it has to be set up this way MapPath("/"). My local asp.net server can't handle the MapPath that way, but our IIS development box has no problem with it and it works fine. Interesting.
How do I get it to save to files?
I believe it's a security violation to go outside the directory structure of the virtual directory in asp.net 2.0 and up. You'll need to make a virtual directory to the directory and use that.
Use
Server.MapPath("~/files")
The ~ represents the root of the web application so the folder returned will be correct no matter which subdirectory you are in.
Try
_page.Server.MapPath("files")
_page.Server.MapPath() will attempt to map from the root of the application (NOT the root of the server).
Try _page.Server.MapPath("../files").
EDIT
You may run into security issues when trying to map outside of your application root. If that is the case, you can do something like this:
Server.MapPath("~").Substring(0, Server.MapPath("~").IndexOf(VirtualPathUtility.ToAbsolute("~").Replace("/", "\"))) + "\files"
This looks rather complex, but essentially says "map my application, then remove the application root from the end and add '\files' instead".