p-net | PROFINET device stack for embedded devices | Automation library
kandi X-RAY | p-net Summary
kandi X-RAY | p-net Summary
PROFINET device stack for embedded devices
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of p-net
p-net Key Features
p-net Examples and Code Snippets
Community Discussions
Trending Discussions on p-net
QUESTION
I wanted to upload files to Google Drive using Google Drive API in ASP.NET MVC C#. While doing that I have followed the below URL: https://qawithexperts.com/article/asp-net/upload-file-to-google-drive-using-google-drive-api-in-aspnet/236
While implementing the code after calling my API google redirect to an error page showing
...ANSWER
Answered 2022-Mar-11 at 10:28The redirect uri must exactly match the one you have registered in Google developer console
If we look at your image you have the following two redirect uris registered
- http://localhost:60581/
- http://localhost:60581/api/TwilioWP/CallGoogleAPI
This means that Google will accept only those two redirect uris from your application. The test is an exact match.
Now if we look at the error message we can see that your application is sending
As you can see this does not match the ones you have registered. What you should do is copy that one and add it.
Note if your ide is changing ports you need to set it to a static port or its not going to work. It needs to match exactly
Google OAuth2: How the fix redirect_uri_mismatch error. Part 2 server sided web applications
Your reall issue.The tutorial you are following uses GoogleWebAuthorizationBroker.AuthorizeAsync
This method is designed for use with an installed application. So in fact the credentials and client type you are using is wrong. If you want to use that code you need to create native or desktop client.
If you try to host this as it is it will attempt to open the web browser on the server. When what you need to do is open the web browser for user consent on the users machine. You should be following web-applications-asp.net-core-3 if you want to be able to authorize a user using your web application.
I offer you my tutorial on Asp .net core 3 and Google login which has a link to the YouTube video on the same topic.
So the real cause of your problem is that you are using code for an installed application which has a default redirect Uri of http://127.0.0.1:{Port}/authorize/
and you are trying to use this for a web application. Which will need to have the host set to that of your web domain.
I have been in touch with the author of the tutorial you are following. I suspect they will be addressing the issue soon. Twitter thread
QUESTION
We have a test environment on a public site. There we use --disable-web-security flag on chrome for the testers to bypass CORS errors for public service calls during manual test phase. And also we have localhost requests on the agent machine. However today with Chrome 98 update we started struggling with the network requests targeting localhost.
The error we get is for the localhost requests from a public site:
Access to XMLHttpRequest at 'https://localhost:3030/static/first.qjson' from origin 'https://....com' has been blocked by CORS policy: Request had no target IP address space, yet the resource is in address space `local`.
The site on localhost is configured to return Access-Control-Allow-* CORS headers including "Access-Control-Allow-Private-Network: true".
And also I do not see any preflight request. Just one GET request with CORS error on it.
We suspect this might be a side effect caused when you disable web security by --disable-web-security. It might be preventing obtaining of the target IP address space. Our assumption is based on the CORS preflight section on https://wicg.github.io/private-network-access/
3.1.2. CORS preflight
The HTTP fetch algorithm should be adjusted to ensure that a preflight is triggered for all private network requests initiated from secure contexts.
The main issue here is again that the response’s IP address space is not known until a connection is obtained in HTTP-network fetch, which is layered under CORS-preflight fetch.
So does anyone know any workaround for Private Network Access with --disable-web-security flag ? Or maybe we are missing something. Thanks for the help.
...ANSWER
Answered 2022-Feb-09 at 04:20Below Steps can help to solve issue in chrome 98, for other browser like edge you need to do similar like chrome.
For MACRequestly with chrome version 98. You need to follow following steps :- Run this command on terminal
defaults write com.google.Chrome InsecurePrivateNetworkRequestsAllowed -bool true
Restart your Browser, Not work then restart your machine
- Run 'regedit' to open windows registry (If permission issue came then run that command with Admin command prompt)
- Go to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome
- Create new DWORD value with "InsecurePrivateNetworkRequestsAllowed" Name
- Change Value to "1"
- Restart your Browser
QUESTION
I have added a webapi project to my solution with a controller to do an HttpGet. The Blazor server project can access it fine locally and deployed. I can make a postman call to the service locally, but the deployed version is giving me the Blazor connection failed message from my _Host file. How would I configure webapi access externally without Blazor interfering?
I think it may be a routing issue of some kind that I need to work out. I am using .NET5 and my webapi startup has this:
...ANSWER
Answered 2022-Jan-05 at 11:45This is just some code to show how you run API controllers and Blazor on the same site.
You normally add controllers to a Blazor Server project like this:
Add the services
QUESTION
Before I start, I've tried all suggestions from the following and none work:
Integration testing ASP.NET Core with .NET Framework - can't find deps.json
https://zimmergren.net/unable-to-find-deps-json-dotnet-azure-devops/
So I'm trying to write some integration tests for dotnet 6. However, my WebApplicationFactory
throws the following error:
System.InvalidOperationException: Can't find '/repos/subscription-info-api/tests/SubscriptionInfoApi.Tests.Integration/bin/Debug/net6.0/...
System.InvalidOperationException Can't find '/repos/subscription-info-api/tests/SubscriptionInfoApi.Tests.Integration/bin/Debug/net6.0/testhost.deps.json'. This file is required for functional tests to run properly. There should be a copy of the file on your source project bin folder. If that is not the case, make sure that the property PreserveCompilationContext is set to true on your project file. E.g 'true'. For functional tests to work they need to either run from the build output folder or the testhost.deps.json file from your application's output directory must be copied to the folder where the tests are running on. A common cause for this error is having shadow copying enabled when the tests run. at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
1.EnsureDepsFile() at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
1.EnsureServer() at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateDefaultClient(DelegatingHandler[] handlers) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateClient(WebApplicationFactoryClientOptions options) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
1.CreateClient() at SubscriptionInfoApi.Tests.Integration.UnitTest1.Test1() in /repos/subscription-info-api/tests/SubscriptionInfoApi.Tests.Integration/UnitTest1.cs:line 14 at SubscriptionInfoApi.Tests.Integration.UnitTest1.Test1() in /repos/subscription-info-api/tests/SubscriptionInfoApi.Tests.Integration/UnitTest1.cs:line 16 at Xunit.Sdk.TestInvoker1.<>c__DisplayClass48_0.<b__1>d.MoveNext() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs:line 264 --- End of stack trace from previous location --- at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func
1 asyncAction) in //src/xunit.execution/Sdk/Frameworks/ExecutionTimer.cs:line 48 at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in //src/xunit.core/Sdk/ExceptionAggregator.cs:line 90
My actual test code is extremely simple:
...ANSWER
Answered 2021-Nov-18 at 21:03You are probably targeting the wrong namespace for Program in your test file (like I was).
I had to add the following at the end of my Program.cs file (last line) to make it visible to my test projects needing it:
QUESTION
Is there any way to change the tag for a given http
method written with minimal api?
ANSWER
Answered 2021-Sep-28 at 11:46I think that all operations that share the same route will get grouped by default
but for explicitly defining the groups you'll need to use the swagger tag which can be used like the this:
QUESTION
I'm going to get so many "okay grandpa" comments for this one.
I've read a dozen articles and every SO question I could find on this subject.
I must have been away too long or missed something completely, because I swear that user authentication used to be very simple. I seem to recall built-in methods and a session on the server simply knowing who the user was via a cookie or similar, with the ability to store information "in session". I don't recall even setting up authentication in years past, it was just built-in to new applications.
Instead, the most succinct guide I could find is very involved. I think I need a token authorization/authentication setup because there may be consumers (like apps) who don't have a typical cookie pattern these days. In my head, the token works like a cookie except it's manually held on the user end and passed via header with each request?
To its credit, the guide worked, at least for logging in and correctly utilizing the simple Authorize
attribute in controllers. However, User.Identity.Name
is always empty, even when User.Identity.IsAuthenticated
is true
, which is perplexing.
How I think auth is working:
- User request hits API with username/password
- Service checks the combination, and returns an encrypted JWT to the user
- The user sends the JWT back with every request
- The server decrypts this JWT to identify the user - this is probably where I'm wrong
So here is where my question comes in:
I need more data about the user, like access to the entire UserModel
with every request, but I don't want to go to the database to find it every time. This is where I think there should just be a session object in memory, but that doesn't appear to be the case with token authentication.
TL;DR:
Where do I put user-specific, short-term ("session") information for consumption in future requests where a user is identified with a JWT in the Authorization header instead of a cookie?
Session state
isn't right, because it's hard-wired to a cookieHttpContext.Items
aren't right, because it's just for the one requestCache
storage isn't right, because it's not user/session specific. I could potentially create a session-like user-keyed storage here but that seems way, way over-engineered for this.- Basically anything where I'm passing all the data (not just a user identifier) to the client then relying on the client to pass it back seems wrong? But feel free to correct me.
ANSWER
Answered 2022-Jan-26 at 18:11The server decrypts this JWT to identify the user This is probably where I'm wrong
The JWT token is not encrypted, its signed so you can't alter it. You can open it if you look at jwt.io for example.
Where do I put user-specific, short-term ("session") information for consumption in future requests where a user is identified with a JWT in the Authorization header instead of a cookie?
You put it in the principle claims of the token. In the guide you linked it wrote:
QUESTION
I am using a tutorial for ASP.NET Core 5.0 + SQL Server, but I am actually using ASP.NET Core 6.0 + Sqlite.
The tutorial has the following code in StartUp.cs
ANSWER
Answered 2021-Dec-07 at 06:30Experienced the same issue i am working with .net6.0 but project is initially setup using .net5
This worked for me -
QUESTION
I've got an application where the EDM datatypes are generated during the runtime of the application (they can even change during runtime). Based loosely on OData DynamicEDMModelCreation Sample - refactored to use the new endpoint routing. There the EDM model is dynamically generated at runtime and all requests are forwarded to the same controller.
Now I wanted to update to the newest ASP.NET Core OData 8.0 and the whole routing changed so that the current workaround does not work anymore.
I've read the two blog posts of the update Blog1Blog2 and it seems that I can't use the "old" workaround anymore as the function MapODataRoute() within the endpoints is now gone. It also seems that none of the built-in routing convention work for my use-case as all require the EDM model to be present at debug time.
Maybe I can use a custom IODataControllerActionConvention. I tried to active the convention by adding it to the Routing Convention but it seems I'm still missing a piece how to activate it.
...ANSWER
Answered 2021-Dec-20 at 06:21So after 5 days of internal OData debugging I managed to get it to work. Here are the necessary steps:
First remove all OData calls/attributes from your controller/configure services which might do funky stuff (ODataRoutingAttribute
or AddOData()
)
Create a simple asp.net controller with the route to your liking and map it in the endpoints
QUESTION
I'm trying to understand how to do integration tests on ASP.NET Core 6 web API controllers. I've tried following all the guides, SO posts and recommendations I could find but for some reason I keep hitting errors that aren't mentioned in the guides.
EventControllerTests.cs
...ANSWER
Answered 2021-Oct-15 at 16:01I can't reproduce this. I created two new projects from the command line on .NET 6 RC1 with
QUESTION
Based on today's announcement of the ASP.NET Core 6 release, it is my understanding that .NET 6 will be immediately available ("day 0 support") on Azure App Services via Early Access:
We are happy to announce that App Service is rolling out day 0 support for .NET 6.0 applications across all public regions and scenarios on both Windows and Linux App Service plans.
After upgrading my ASP.NET Core application to ASP.NET Core 6, configuring my Azure App Service to use .NET 6, and publishing my application to my existing Azure App Service, however, I get an HTTP Error 500.31 with the specific message:
The framework 'Microsoft.NETCore.App', version '6.0.0' (x64) was not found.
Notably, the only .NET 6 runtime it lists as available is RC2 (6.0.0-rc.2.21480.5
), not today's release version.
To facilitate this, I performed the following steps:
- Project file (
csproj
): Updated theto target the
net6.0
- Publishing profile (
pubxml
): Updated theto target the
net6.0
- Project file (
csproj
): Updated allMicrosoft.AspNetCore.*
NuGet packages to 6.0.0 - Azure App Service Configuration: Updated the .NET Version to ".NET 6 (Early Access)"
When accessing my Azure App Service site with detailed errors enabled, however, I receive the following error:
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies Common solutions to this issue:The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Specific error detected by ANCM: ...
ANSWER
Answered 2021-Nov-09 at 06:50I have successfully deployed to an App Service using the Self-Contained Deployment Mode. All I did is change the TargetFramework to net6.0 in the csproj file and update the nuget all packages to 6.0.0.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install p-net
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page