I have a very simple Addresses Controller that works when I host the asp.net web app on IIS Express.
public class AddressesController : ApiController
{
public int GetAddresses()
{
//return db.Addresses.Select(x => x.AddressID);
return 3;
//"select AddressID from Addresses";
}
I call the api successfully locally with
GET https://localhost:44385/api/Addresses,
but I want to be able to call it when the app is hosted on azure.
I published my app using publish, and the index page loads fine.
However, the api endpoint is not accessible.
I verified that Azure's
"App Service Authentication" is Off for the application. If the authentication is off, shouldn't I be able to directly hit this endpoint?
Response I get is
500 Internal Server Error:
{
"Message": "An error has occurred."
}
When I try to set breakpoints using the cloud remote debugger, the break points in the HomeController containing the Index Page returns fine.
however, the AddressesController's break point does not get hit. It makes me wonder if creating the controller failed or the routes for the app were not configured properly.
However, when I try to set a breakpoint in route configuration it doesn't get hit when I publish the website (not sure why? maybe the debugger attaches after the website is fully loaded)
edit: thanks to the kind help, I now have more useful error information.
{
"Message": "An error has occurred.",
"ExceptionMessage": "Multiple types were found that match the controller named 'Addresses'. This can happen if the route that services this request ('api/{controller}/{id}') found multiple controllers defined with the same name but differing namespaces, which is not supported.\r\n\r\nThe request for 'Addresses' has found the following matching controllers:\r\nWebApplication1.Controllers.AddressesController\r\nRestAPI.Controllers.AddressesController",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.SelectController(HttpRequestMessage request)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
}
the namespace I used was RestAPI.Models. A search doesn't reveal "WebApplication1.Controllers." anywhere in my project. Very strange
There is an issue when publishing if the controller has changed and you don't choose
the "Remove Additional Files at Destination" when publishing to azure.
https://github.com/microsoft/botframework-sdk/issues/3898
Thanks for the help houssem
Related
Getting this error:
Access to fetch at 'https://myurl.azurewebsites.net/Player/1' from origin 'http://localhost:19006' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I'm not the first with this error, but I feel like I have tried everything that one can find through searching for the problem. I'm developing a web API with ASP.net core, that's supposed to communicate with my react-native frontend. Problem is, I cannot for the life of me get the connection to work.
In program.cs I have added
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
builder.Services.AddCors(options =>
{
options.AddPolicy(name: MyAllowSpecificOrigins,
policy =>
{
policy.AllowAnyMethod();
policy.AllowAnyHeader();
policy.AllowAnyOrigin();
});
});
and
app.UseCors(MyAllowSpecificOrigins);
I have tried adding no cors to the method itself
[DisableCors]
[HttpGet("{id}")]
public List<Player> GetPlayers(int id)
{
return (from c in _context.Player.Take(1)
where c.PlayerId == id
select c).ToList();
}
I even deployed the server and database on Azure (I was supposed to sooner or later anyway) just hoping that would allow me to get it to work. The API runs fine if I visit the URL and run it through that one. It also works great if I host it locally and go through the web.
On Azure I've changed my cors settings to allow everything:
I can even access the API through expo web if I run it locally at the same time. But I need to be able to do it through my phone as well, or at least an android emulator. Neither of those works for neither a locally hosted server, or one that's on Azure.
How can I solve this?
Actually, shortly after setting my Azure cors settings, it did indeed start to work. Finally, I can at least demo it. Unfortunately, I still have no solution that solves it when hosting locally.
Using Laravel 7, and this package I tried to create an oath using an orcid socialite registration using a simple link.
DOCUMENTATION ("How does “3 legged OAuth” work?"):
https://info.orcid.org/documentation/integration-and-api-faq/#easy-faq-2537
Login Using Orcid
When the user clicks the button, a redirection occurs, but when the redirection occurs the system does not allow the user to "Grand" or "Deny" the connection to the service. Instead, a blank page redirects the user back to my project.
During the whole process, I can see that the URL changes, to Orchid.org/[etc][client_id] so I think a connection is established with Orcid.
But then I get a URL orcid/callback#error=invalid_scope
And an error message:
Server error: POST https://orcid.org/oauth/token resulted in a 500 Internal Server Error response: {"error":"server_error","error_description":"An authorization code must be supplied."}
Did I miss something?
my .env variables
ORCID_CLIENT_ID=XXX
ORCID_CLIENT_SECRET=XXX
ORCID_REDIRECT_URL=https://WEE/login/orcid/callback
ORCID_ENVIRONMENT=production
My LoginController functions for my routes:
public function orchidLogin(){
return Socialite::driver('orcid')->redirect();
}
public function handleOrcidCallback(Request $request){
//How do I get the data for registration???
}
My routes:
Route::get('login/orcid', 'Auth\LoginController#orchidLogin');
Route::get('login/orcid/callback', 'Auth\LoginController#handleOrcidCallback');
After facing the same issue, and dig deep in the mentioned package found that the package by default assume scopes in vendor\socialite\orcid\provider which was protected $scopes = ['/authenticate','/read-limited'];
if you only registered for public API then the scope '/read-limited' not available for you. that's why you get the error #error=invalid_scope and as per ORCID documentation Here the scope /read-limited (for Member API only).
so to fix the issue you have 2 options:
register for member API.
or assign public API scopes only.
like Socialite::driver('orcid')->scopes(['/authenticate','openid'])->redirect()
Hi I have done with following steps to implement Universal Link for IOS.
1.My sub domain is npd.nowconfer.com, and my apple-app-site-association file contains,
{
"applinks": {
"apps": [],
"details": [
{
"appID":"R3UDJNSN2P.com.sampleUniversal.teledna",
"paths": ["*"]
}
]
}
}
this file is uploaded into my subdomain npd.nowconfer.com and its serveing over https.
2.I tested using AASA Validator i.e https://branch.io/resources/aasa-validator/#resultsbox and i got Test result as all pass.
you can see attached screenshot.
3.Now In app side,my colleague did configuration such as
Added the domain to Capabilities i.e applinks:nowconfer.com and applinks:npd.nowconfer.com
Handled Universal Links in app i.e in delegate like this
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
NSURL *url = userActivity.webpageURL;
// handle url
}
4.my universalink is https://npd.nowconfer.com:5000/calendar/deeplink?url=nowconfer when i click on this link from email ,my app is not opening instead it is redirecting to app store(becasue server side request came handling to redirect app shore if app is not installed on device)
But when i tested universalink validator here https://search.developer.apple.com/appsearch-validation-tool ,i have got some error
Link to Application : Error no apps with domain entitlements
The entitlement data used to verify deep link dual authentication is from the current released version of your app. This data may take 48 hours to update.
I have seen lot of tutorials but not used anything for me.Can you guys help me to figure out what is happening here?
Universal Links have to be standard http:// or https:// links. This means they need to use the standard web ports, of which 5000 is not one. That is why your link is not working — it's not actually a valid Universal Link.
The Apple validator checks for some additional things, and is also somewhat unreliable. This particular error message is confusing, but it has nothing to do with whether your Universal Linking configuration is correct. What it actually means is Apple can't detect applinks: entitlements and 'proper' handling of passed-in link values in the version of your app that is currently live in the App Store. This is expected if you are just implementing Universal Links for the first time. You don't need to worry about this — a number of large and successful apps with working Universal Links implementations fail this step too.
I have an Azure Mobile App that has some methods that generate 500 errors but does not record any exceptions in Application Insights and no exceptions are thrown inside my code. I have been able to determine that normal TableController methods work fine, but custom methods do not. Also, I can remote debug the code and watch it finish executing without any exceptions being thrown. It should also be noted that I did not have this problem when this project was a Mobile Service. Here is an example method that fails:
private readonly MobileServiceContext context; //Autofac injection
private readonly IUserHelper userHelper; //Autofac injection
[HttpGet, Route("api/Site/{id}/Users")]
public async Task<HttpResponseMessage> Users(string id)
{
var userId = await userHelper.GetUserIdAsync(User, Request);
var query = context.UserSiteMaps.Include(x => x.User).Where(map => map.SiteId == id);
var auth = query.FirstOrDefault(x => x.UserId == userId && x.IsAdmin);
if (auth != null)
{
return Request.CreateResponse(HttpStatusCode.OK, query.Select(map => map.User));
}
return Request.CreateUnauthorizedResponse();
}
The deepest error log that I have been able to obtain is the detailed error page from IIS:
Module __DynamicModule_Microsoft.Owin.Host.SystemWeb.OwinHttpModule, Microsoft.Owin.Host.SystemWeb, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_9de2321b-e781-4017-8ff3-4acd1e48b129
Notification PreExecuteRequestHandler
Handler ExtensionlessUrlHandler-Integrated-4.0
Error Code
0x00000000
I haven't been able to generate a more detailed error message and I have no idea what Owin is upset about here since other method return requests just fine. Am I doing something I shouldn't?
Any help would be greatly appreciated!
Update : Here is the full error message that I have been able to get.
I have also been able to narrow the cause down a bit. If I replace the query.Select(map => map.User) object in the response with a simple string, it returns that string without complaint. However, if I stringify the response myself and pass that in, I get 500s again. Could it be some serializer setting problem?
The best way to track down the issue is to turn on exception stack traces for you app and to turn on logging on your Mobile App backend.
See Server Side Logging in the Mobile Apps wiki and Enable diagnostics logging for web apps in Azure App Service. You can also remote debug your service to see the exact error, see Remote debugging .NET server SDK.
I'm writing a very small app to create and test caml querys for sharepoint. While executing the GetListItems method I'm receiving the following exception;
System.Net.WebException: "The request failed with an empty response."
The service is located on a https address (ssl). I setup the service as follows;
result = new ListService.Lists();
result.Url = siteUrl;
result.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
I invoke the GetListItems() method as follows;
xmlResult = spList.GetListItems(listName, string.Empty, camlQuery, null, string.Empty, null, string.Empty);
I'm trying to find out why I'm getting the empty result message. I've also tried other methods (i.e. GetListCollection) but to no avail.
At first I thought that the problem might be the URL (http instead of https), but that is not the case. I even checked it with wireshark to make sure the right URL is used.
Did someone come accross this problem and how did you solve it?
OMG...! I've solved it after all. After posting this question, I tried to get hold of the wsdl the check the service itself. When I checked it via internet explorer all was ok. When I tried to add it as a reference in VS it went wrong. So something was not ok. Then it occured to me that there was a new login screen for our company network.
After some quick phonecalls I learned what the problem was; IT Services installed a ISA 2006 server and 'forgot' to tell me. The ISA server was blocking all trafic on the HTTPS port (443) for unkown programs and or clients. That's why internet explorer presented me with a new and shiny login dialog.