https://github.com/megabytemark/intradotnet-aspnetcore-wasm
WebAssembly polyfill for enabling Windows features when targetting an intranet environment.
https://github.com/megabytemark/intradotnet-aspnetcore-wasm
Last synced: 12 months ago
JSON representation
WebAssembly polyfill for enabling Windows features when targetting an intranet environment.
- Host: GitHub
- URL: https://github.com/megabytemark/intradotnet-aspnetcore-wasm
- Owner: MegaByteMark
- License: mit
- Created: 2024-12-13T19:33:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-18T17:24:13.000Z (over 1 year ago)
- Last Synced: 2025-04-10T00:06:32.176Z (about 1 year ago)
- Language: C#
- Size: 737 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IntraDotNet.AspNetCore.Wasm
WebAssembly polyfill for enabling Windows features when targeting an intranet environment.
## Features
- Browser console logging
- HTTP request handling with browser credentials
## Installation
To install the package using the `dotnet` CLI, run the following command:
```sh
dotnet add package IntraDotNet.AspNetCore.Wasm
```
## Usage
### Browser Console Logging
You can add browser console logging to your ASP.NET Core application by using the AddBrowserConsole extension method.
```csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using IntraDotNet.AspNetCore.Wasm.BrowserConsole;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Logging.AddBrowserConsole();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.Run();
```
#### Configuration
You can configure the logging level in your appsettings.json file:
```json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "None",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
```
### HTTP Request Handling with Browser Credentials
You can use the BrowserIncludeRequestCredentialsDelegatingHandler to include browser request credentials in your HTTP requests. Register the handler with dependency injection and use it in your services.
```csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Net.Http;
using IntraDotNet.AspNetCore.Wasm.Fetch;
var builder = WebApplication.CreateBuilder(args);
//Add AddBrowserIncludeRequestCredentials to the HttpClient builder
//See example project, Pages/Home.razor for an example of using HttpClient with this handler
builder.Services.AddHttpClient("MyClient")
.ConfigurePrimaryHttpMessageHandler();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.Run();
```
## Contributing
Contributions are welcome! Please open an issue or submit a pull request.
## License
This project is licensed under the MIT License.