|
You do need to mark the method with [HttpPost] (or technically, [HttpPut] if this is a REST API).
The client call is using the wrong HTTP method.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
ya, that was it. Thank you sir!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'm working on a WPF app against an ASP.Net MVC Web API.
I'm trying to implement a delete in my Operator controller. I'm getting
System.Exception: 'An error occured calling the WebAPI.
The status code is 'MethodNotAllowed'.
The error message is {"Message":"The requested resource does not support http method 'DELETE'."}'
Client Side Proxy
public async Task DeleteOperatorAsync(Guid id)
{
await Task.Factory.StartNew(() =>
{
var webAPIExecutor = new WebAPIExecutor(ServerUrl, "/Operator/Delete/", Method.DELETE);
webAPIExecutor.AddParameter(id, "id");
webAPIExecutor.Execute();
});
}
Controller
[HttpDelete]
public void Delete(Guid id)
{
IBusinessLayer bl = new BusLayer();
bl.DeleteOperator(id);
}
The class WebAPIExecutor is working fine for all other calls so it's most likely not the problem, but I can post it if someone wants to see it.
Fiddler shows this info
DELETE <a href="http://localhost:53175/api/Operator/Delete/">http:
Accept: application/json, text/json, text/x-json, text/javascript, application/xml, text/xml, text/plain
User-Agent: RestSharp/106.6.7.0
Content-Type: application/json
Host: localhost:53175
Content-Length: 38
Accept-Encoding: gzip, deflate
"77932bef-1b12-4204-9bd7-9a50f854a72a"
All other Web API calls are working. Canyone know what's wrong?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I suspect it's because you're passing the parameter in the request body, rather than in the URL:
ASP.NET web API HTTP Delete 405 Method Not Allowed - Stack Overflow[^]
You might need to add the [FromBody] attribute to your parameter:
Using [FromBody] | Parameter Binding in ASP.NET Web API | Microsoft Docs[^]
Slightly off-topic:
public async Task DeleteOperatorAsync(Guid id)
{
await Task.Factory.StartNew(() =>
{
var webAPIExecutor = new WebAPIExecutor(ServerUrl, "/Operator/Delete/", Method.DELETE);
webAPIExecutor.AddParameter(id, "id");
webAPIExecutor.Execute();
});
}
That just looks nasty. It would be better to make your WebAPIExecutor class expose async methods. The Execute method is IO-bound, not CPU-bound, so pushing the work onto a background thread doesn't make much sense.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That did it. I set the FromBody attrib and it worked.
As far as the Executor, here's the Execute code:
public void Execute()
{
URL = client.BaseUrl + request.Resource;
IRestResponse result = null;
try
{
result = client.Execute(request);
int resultCode = (int)result.StatusCode;
if (resultCode > 299)
{
string message = string.Format("An error occured calling the WebAPI. {0} The status code is '{1}'. {2} The error message is {3}",
Environment.NewLine, result.StatusCode, Environment.NewLine, result.Content);
throw new Exception(message);
}
}
catch (Exception e)
{
throw e;
}
}
Not sure what in here I could await. The RestClient doesn't expose any async methods.
Your thoughts?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Is that RestSharp[^]?
If so, there's an ExecuteTaskAsync method that would work:
RestSharp/RestClient.Async.cs at 64357df6f8c428f3b39e78ab4b3034596dd2e953 · restsharp/RestSharp · GitHub[^]
Also:
Quote:
catch (Exception e)
{
throw e;
}
Don't do that. You've just thrown away the stack trace of the exception. If you have to catch and rethrow, just use throw; instead of throw e; . But in this case, since you're not doing anything with the exception, you can just remove the try..catch block.
And:
Quote:
throw new Exception(message);
I wish Microsoft had made the Exception class abstract ; there's never a good reason to throw new Exception(...); instead of using a more specific exception type.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: If so, there's an ExecuteTaskAsync method that would work:
You're right. Not sure why I didn't se that.
As far as the rest... we're just prototyping right now, so I'm throwing just in the interim. We'll be adding in more robust exception handling later.
Thanks for all your help
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Hello everyone.
I have a asp.net core 2.1 project, where i need to use the adfs as an external authentication provider.
I just can't find a working solution and i'm getting a little bit desperate, so can anyone please help me!
Prefereably i'm looking for a solution via Oauth2 protocol.
I found one working solution with WS-federation (cookie based) - LINK, the authentication work just fine, the app first checks if an user is logged in, if not it redirects to adfs external login page and after a successful login it redirects back to the app and shows the data. There is just one small problem, i don't know how to get user info (user id, upn ...).
Thank you in advance and have a nice day.
.
|
|
|
|
|
Caveat - I don't use oAuth.
_dk6607 wrote: i don't know how to get user info (user id, upn ...).
I would think you would just get the fact that the user is authenticated/Authorised as a return from the external logon. UserID and password should not be available.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
If you looked at the article from the link, you would see you can get a lot of information about the user, who has logged in, dependes on the configuration on the adfs.
The adfs communicates with ad (active directory) and gets the user info back as claims. Then the adfs returns data to the app as an encrypted token.
Here is the problem, i don't know how to solve, get the claims out of the token.
|
|
|
|
|
|
I've been googling this topic and I'm finding conflicting messages regarding which one to choose, as well as in CRaP ( Core Razor Pages ).
I suspect that Microsoft will abandon MVC in the next year or so, so there is that concern.
Organizationally speaking, CRaP is easier on the solution explorer browsing.
I read one view that said MVC is better for large apps, and CRaP was better for small single-page apps, but I read another item that says MVC doesn't scale as well as CRaP.
----------------
Regarding CRaP:
There appear to be two ways to "compartmentalize" large sites:
0) Add an Areas folder in the project root (requires a few settings changes in the app to allow areas)
1) Add a Features folder to the (generated) Pages folder
It seems to me that either is viable, but I'm wondering which would be "better", and why.
---------------------
Apparently you can mix/match MVC and CRaP, but I want to avoid doing that (to mitigate complexity), thus rendering that possibility off-topic for this thread.
Discuss...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
John Simmons / outlaw programmer wrote: I suspect that Microsoft will abandon MVC in the next year or so, so there is that concern.
They've barely abandoned WebForms, so I seriously doubt they'll be chucking MVC under the bus any time soon.
Also, it's all "open source" now, so it would be much harder for Microsoft to abandon the project if the community still wants to keep it running.
John Simmons / outlaw programmer wrote: I read another item that says MVC doesn't scale as well as CRaP.
Were they comparing CRaP to "Core" MVC, or MVC5? I've seen lots of talk about Core being faster than MVC5 - and potentially getting even faster when they bring it back in-process in IIS - but I've not seen anyone suggesting that there's a difference between Core MVC and CRaP.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Were they comparing CRaP to "Core" MVC, or MVC5?
I suspect it was MVC5.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I have a Core 2.1 Razor Pages solution that contains a number of discreet web apps. All of these apps share a number of css, image and partial page files.
To "share" these files, I created a solution folder (in the VS2017 Solution Explorer) called "Common", and inside that folder, I put various files into this folder.
Question - Even though I created the folder in the solution explorer, there is no "Common" folder anywhere in the folder hierarchy. Instead, all of the files I put into the Common folder were placed in the solution's root folder. Did I do it wrong?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
What is different is:
IT WORKS
<div class = "carousel-inner">
<div class = "carousel-item active">
<img src = "https://www.w3schools.com/bootstrap4/la.jpg" alt = "Los Angeles" height = "100">
</ Div>
<div class = "carousel-item">
<img src = "https://www.w3schools.com/bootstrap4/la.jpg" alt = "Chicago" height = "100">
</ Div>
<div class = "carousel-item">
<img src = "https://www.w3schools.com/bootstrap4/la.jpg" alt = "New York" height = "100">
</ Div>
</ Div>
from this:
IT DOES NOT WORK
<div class = "carousel-item active">
<img src = "advertisement / reklama1.jpg" alt = "ad1" height = "100">
</ Div>
<div class = "carousel-item">
<img src = "advertisement / reklama2.jpg" alt = "ad2" height = "100">
</ Div>
<div class = "carousel-item">
<img src = "advertisement / reklama3.jpg" alt = "reklama3" height = "100">
</ Div>
Maybe I'm dumb, I do not know.
I even entered the ADDRESS OF YOUR WEBSITE and it does not work.
But as there are pictures from w3schools it works.
WTF?
I also saw:
https://github.com/Dogfalo/materialize/issues/3899
https://github.com/archriss/r[...]tive-snap-carousel/issues/371
But it does not tell me anything.
|
|
|
|
|
First of all, is this based on an article somewhere here on the site? If it is, that's where you should be asking your questions. It's extremely unlikely that the author will come across this post and realise it's for them.
Second, when talking about an error, it's a good idea to tell us what the problem actually is. Right now, we have to take a look at your question and guess what the problem is.
Third, the structure of the divs is different - you don't have a containing div with carousel-inner. Now, you might have it in your code and you just forgot to post it here but without the context of the problem, we can't tell.
Fourth, the image src is invalid. You have stray spaces in the src.
This space for rent
|
|
|
|
|
There is no problem with paths. The problem was the name of the file and directory. And so the name.
The DIV structure is the same, in the second chapter it did not copy to me. The ad blocking tool cut out this carousel by the name of the files in the format "advertisement1" and the folder: "advertisement". After changing the file name to 1.jpg and folder on "aa" the problem disappeared.
|
|
|
|
|
Members
1 posts
OFFLINE
Local time:04:16 AM
Posted Today, 04:16 AM
I'm unsure if I'm posting this in the correct forum but here goes:
I'm in the process of creating a website for our door manufacturing business. As part of the website I want to add a 'design your own doorset' feature which would allow the customer to enter all of their specifications in regard to quantity, sizes, component type, confirm the order,.and then pay at checkout.
Here is an example of another company who have a similar offering:
https://www.safelincs.co.uk/custom-30-and-60-minute-fire-doors-fd30-fd60/
The solution I want to create is functionally the same as the above website, however with more size, type and finish options. I find that the above website does well in explaining what each option delivers but it isn't aesthetically pleasing and wastes a lot of space with text.
As I'm not educated in website building I am using Wix which does permit the embedding of html. That being said, I'm looking for advice as to whether I can simply have this software written then embed it on Wix or whether I need to also find someone to build a new website from scratch.
I'd like advice on what type of professional(s) I should be hiring for this type of work. What should they be specialised in?
|
|
|
|
|
The person that you hire would be the best person to ask these questions. Developers tend to be an opinionated lot, and there are often many paths to a good solution, and we wouldn't want to prejudice you to specific viewpoints in case your developer has differing ones.
You'll want to hire a web developer with business development experience, since payment portals are not something that you want to play around with. Optionally, you'll want someone with design experience as well, but that might be a task better relegated to someone else, budget withstanding. Generally developers are weak on design, and designers are weak on development; we just value different things.
If you currently have any order processing automation, you will want to talk to whomever handles the database to coordinate other skills that might be needed; namely experience with whatever database your company uses.
My last suggestion is that you look for someone that can claim some security experience or some sort of security certification. That's a CYA move, but realistically a dev that thinks about security while they code will give you a better (publicly accessible) product at the end than one who doesn't.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
Greetings,
I am attempting to create PIVOT data where amountPaid is displayed under registration_Date as in the following format
:
2018 2019, etc
300.00 160.00. etc
So far, the result is not coming out right.
Instead of the amountPaid displaying on the year colums, reg_fee amount is displaying on the first column.
This is driving me nuts.
I am creating the pivot data dynamically. This way, any new year created is displayed with amountPaid as the value.
This is the code I am using:
ALTER PROCEDURE [dbo].[uspGetPivotedData]
AS
DECLARE @cols AS NVARCHAR(MAX),
@query AS NVARCHAR(MAX);
SET @cols = STUFF((SELECT distinct ',' + QUOTENAME(m.registration_date)
FROM Members m
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
set @query = 'SELECT TransactionID,
AmountOwed,
FullName,
Gender,
phone,
EmailAddress,
Address,
EventYear,
Description,
Reg_Fee
' + @cols + ' from
(
SELECT t.TransactionID,
t.AmountOwed,
m.FullName,
m.EmailAddress,
m.Gender,
m.Phone,
m.Address,
t.EventYear,
p.Description,
Reg_Fee,
m.registration_date,
t.AmountPaid
from dbo.Transactions AS t INNER JOIN dbo.Members AS m ON t .MemberID = m.MemberID INNER JOIN
dbo.PaymentTypes AS p ON t .TypeID = p.PaymentTypeID
) x
pivot
(
max(AmountPaid)
for registration_date in (' + @cols + ')
) p '
EXECUTE sp_executesql @query
registration_date is of int data type.
Any ideas what I am doing wrong?
|
|
|
|
|
You're missing a comma after the Reg_Fee column.
'SELECT
...
Description,
Reg_Fee
' + @cols + ' from
...
You've also posted this in the "Web Development" forum, when it should really have been in the Database forum[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks so much sir.
Doofus me!
Sorry about posting here instead of the DB forum.
|
|
|
|
|
I've been struggling with getting an Angular 6 app to sort the results of an WebAPI call, and it turns out that the root cause is case sensitivity on the object properties. And I can see 'where' the differing cases come from, but I can't see the where/why.
I have a class for my object:
export class App
{
id: number;
name: string;
description: string;
isEnabled: boolean;
shortName: string;
displayOrder: number;
} And my web service returns JSON like:
{"ID":1
,"Name":"Matterhorn User Management"
,"Description":"User and Role management for Matterhorn applications."
,"IsEnabled":true
,"ShortName":"MUM"
,"DisplayOrder":10} To retrieve the data I've got the following function in my service:
getApplications(): Observable<App[]>
{
let apiURL: string = this.baseUrl + 'usermanagement/applications/read';
return this.http.get<App[]>(apiURL);
}
And finally my component calls that service function:
getApps(): void
{
this.appsService.getApplications()
.subscribe(data =>
{
this.apps = data.sort((a, b) => a.DisplayOrder - b.DisplayOrder);
});
}
So the problem was that data structure matches the JSON capitalization and not my local TS object one, and I had to use DisplayOrder not displayOrder (and TS now whinges at me).
But isn't Angular now supposed to map and convert JSON automatically (I know this was a specific step in the past)?
And surely your local objects don't have to match the case sensitivity of the JSON provided by others.
|
|
|
|
|
Hi My Website "stelleninfotech.com" is showing error.when we refresh it then its work properly.
Any Idea?
Displaying Error
Warning : opendir(cache/domains/): failed to open dir: No such file or directory in /var/www/html/cms/application/models/api_model.php on line 14
Warning : readdir() expects parameter 1 to be resource, boolean given in /var/www/html/cms/application/models/api_model.php on line 15
Notice : Undefined variable: domains in /var/www/html/cms/application/models/api_model.php on line 22
Warning : in_array() expects parameter 2 to be array, null given in /var/www/html/cms/application/models/api_model.php on line 22
bad
|
|
|
|
|