Click here to Skip to main content
15,885,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
When I use ip address with port number as url value in my config file I am getting the following error

C#
System.NotSupportedException: The given path's format is not supported


But this is working fine when I use a website like "http://www.google.com"
What I have to use to make this ip url format supported...

What I have tried:

PFB is the config file I tried on


 <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="baseURL" value="https://192.168.0.33:6060" />
  </appSettings>
</configuration> 
Posted
Updated 1-Jun-16 4:03am
v2
Comments
Richard MacCutchan 31-May-16 3:18am    
Where and when does the exception occur, and what is the code doing at that point?
Dineshbabu Uvarajulu 31-May-16 3:23am    
The exception is happening immediately after I execute the code
Richard MacCutchan 31-May-16 3:41am    
What code? Please understand that we cannot see your screen or read your mind. Without the full details of what is happening there is no way we can begin to make any suggestions.
Dineshbabu Uvarajulu 31-May-16 4:52am    
ok, above given is my config file. I am calling that url in the below code

public static string BaseUrl
{get
{return System.Configuration.ConfigurationManager.AppSettings["baseURL"];}
}
But its giving me the exception. This is working fine when I use a domain url eg: www.google.com
Richard MacCutchan 31-May-16 5:43am    
I have just tried it and it works fine. I can only assume that the exception is actually occurring somewhere else. Can I suggest you use your debugger to check the exact line of code that throws the exception, then edit your question and show the code you find.

C#
string fileTime = string.Format("{0:MM-dd-yyyy} {1}\\", startTime, BaseUrl.Replace("https://", "").Replace("http://", "").Replace("www", "").Replace(".", "").Replace("com", "").ToUpper());

Writing statements like that is just asking for trouble.
 
Share this answer
 
v2
Try using the WebConfigurationManager class.
see below snippet
my web config is as follows
XML
<configuration>
   ....
   <appSettings>
      <add key="PFUserName" value="myusername"/>
      <add key="PFPassWord" value="mypassword"/>
   </appSettings>
   ....
</configuration>

read it
C#
string userName = WebConfigurationManager.AppSettings["PFUserName"]
 
Share this answer
 

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