C# | Invalid URI: The format of the URI could not be determined
try putting the protocol prefix in front the ip, i.e. in your case "http://"
The format of the URI could not be determined when combining absolute and relative URLs in C#
The "/AdvancedCalender/Calenders/Versions"
is a relative URI, so you need to tag is like that:
Uri relativeUri = new Uri("/" + directory, UriKind.Relative);
How to fix Invalid URI: The format of the URI could not be determined in asp.net core problem
For loggingBuilder.AddSeq("Seq");
, you need to pass url instead of Seq
.
//
// Summary:
// Extends Microsoft.Extensions.Logging.ILoggerFactory with methods for configuring
// Seq logging.
public static class SeqLoggerExtensions
{
//
// Summary:
// Adds a Seq logger configured from the supplied configuration section.
//
// Parameters:
// loggerFactory:
// The logger factory.
//
// configuration:
// A configuration section with details of the Seq server connection.
//
// Returns:
// A logger factory to allow further configuration.
public static ILoggerFactory AddSeq(this ILoggerFactory loggerFactory, IConfigurationSection configuration);
//
// Summary:
// Adds a Seq logger.
//
// Parameters:
// loggerFactory:
// The logger factory.
//
// serverUrl:
// The Seq server URL; the default is http://localhost:5341.
//
// apiKey:
// A Seq API key to authenticate or tag messages from the logger.
//
// minimumLevel:
// The level below which events will be suppressed (the default is Microsoft.Extensions.Logging.LogLevel.Information).
//
// levelOverrides:
// A dictionary mapping logger name prefixes to minimum logging levels.
//
// Returns:
// A logger factory to allow further configuration.
public static ILoggerFactory AddSeq(this ILoggerFactory loggerFactory, string serverUrl = "http://localhost:5341", string apiKey = null, LogLevel minimumLevel = LogLevel.Information, IDictionary<string, LogLevel> levelOverrides = null);
//
// Summary:
// Adds a Seq logger.
//
// Parameters:
// loggingBuilder:
// The logging builder.
//
// serverUrl:
// The Seq server URL; the default is http://localhost:5341.
//
// apiKey:
// A Seq API key to authenticate or tag messages from the logger.
//
// Returns:
// A logging builder to allow further configuration.
public static ILoggingBuilder AddSeq(this ILoggingBuilder loggingBuilder, string serverUrl = "http://localhost:5341", string apiKey = null);
//
// Summary:
// Adds a Seq logger configured from the supplied configuration section.
//
// Parameters:
// loggingBuilder:
// The logging builder.
//
// configuration:
// A configuration section with details of the Seq server connection.
//
// Returns:
// A logging builder to allow further configuration.
public static ILoggingBuilder AddSeq(this ILoggingBuilder loggingBuilder, IConfigurationSection configuration);
}
If you want to passing the configuration from appsettings.json
, define the appsettings.json
like
"Seq": {
"ServerUrl": "http://localhost:5341",
"ApiKey": "1234567890",
"MinimumLevel": "Trace",
"LevelOverride": {
"Microsoft": "Warning"
}
}
And using like loggingBuilder.AddSeq(Configuration.GetSection("Seq"));
.
If you need to combine serilog
and Seq
, refer Using Serilog.
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.Seq("http://localhost:5341")
.CreateLogger();
Invalid URI: The format of the URI could not be determined, Need a solution or alternative method to create a connection to the DB
UPDATE
This problem is very strange, I tried to reduce the package version, but they all work normally. So I think the problem is not the package version.
Maybe you can debug your program with breakpoints. Like ,
string URL = Configuration["CosmosDB:URL"];
string PrimaryKey = Configuration["CosmosDB:PrimaryKey"];
services.AddSingleton<IDocumentClient>(x => new DocumentClient(new Uri(Configuration["CosmosDB:URL"]), Configuration["CosmosDB:PrimaryKey"]));
If the problem is not solved, there really is no better way to configure the parameters
PRIVIOUS
Your code is right, but now you face this issue. I guess it may be caused by the version of the package.
I have created a core app which db is in local and try it success. My package version like bellow.
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.8.0" />
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.10.1" />
</ItemGroup>
So I suggest you update the package version first. If this is not possible, I suggest that you recreate the demo for testing. Perhaps the other part of the code interfered.
Invalid URI: The format of the URI cannot be determined
ConfigurationManager.AppSettings["FTP"]
is an invalid URI. You need to fix that.
You probably need to add ftp to the url in the app settings.
Like this "ftp://192.168.1.1:21"
In the end call GetResponse
using (var resp = (FtpWebResponse) ftpRequest.GetResponse()){
Console.WriteLine(resp.StatusCode);
}
nombre + @"//Images//test"
does not create a valid url. You are using double /
Also make sure directory Images
exists.
Invalid URI: The format of the URI could not be determined - C#
You have to use UriKind.Relative
myResourceDictionary.Source = new Uri("../Resources/Styles/Shared.xaml", UriKind.Relative);
Related Topics
Show Controls Added Programmatically in Winforms App in Design View
How to Format Datetime to Web Utc Format
Nsubstitute - Testing for a Specific Linq Expression
How to Get a Type's Alias Through Reflection
Accessing All the Nodes in Treeview Control
How to Create a Directory on Ftp Server Using C#
Print List of Objects to Console
What to Use: Var or Object Name Type
How to Split a String into Multiple Values
Linq to Entities Does Not Recognize the Method 'System.Web.Mvc.Fileresult'
Owin's Getexternallogininfoasync Always Returns Null
Using Bindingoperations.Enablecollectionsynchronization
When to Use a Sortedlist<Tkey, Tvalue> Over a Sorteddictionary<Tkey, Tvalue>
No Definition Found for Getactiveobject from System.Runtime.Interopservices.Marshal C#