|
But they're void methods. There's nothing to return
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Change your void methods to return IActionResult , and return a result representing the status of the operation.
Controller action return types in ASP.NET Core web API | Microsoft Docs[^]
Eg:
[HttpDelete]
public IActionResult Delete(int id)
{
if (!RecordExists(id)) return NotFound();
DeleteTheRecord(id);
return Ok();
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm using .Net Framework. I can't use IActionResult
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
For .NET Framework, you just need to use IHttpActionResult instead.
[HttpDelete]
public IHttpActionResult Delete(int id)
{
if (!RecordExists(id)) return NotFound();
DeleteTheRecord(id);
return Ok();
} Action Results in Web API 2 - ASP.NET 4.x | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
I am working on a project that requires me to code multiple text blocks over an image (a diagram). But the way I coded it will not allow the image to render in any other page view other than full screen. When changing the screen size, the text gets all jumbled up. Can you please help me understand the correct way to code text over an image and have the text convert with the image as the screen size changes?
|
|
|
|
|
I wanted to ask how should we code the domain code ourselves? That is, to register a domain for our website and not to get it from somewhere else? What to learn for it Or what book he read
|
|
|
|
|
You need to contact the domain registrar in your country (Google should find them).
|
|
|
|
|
|
Don't type the entire question in the "Subject" box. Instead, provide a short summary of the problem, and type the full question in the "Message" box.
In this case, "Domain registration" would have been a more suitable subject.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello everyone,
I've a general (beginner) question about web programming. I'd like to display content graphically on a web page whose data is generated by a permanently running C++ program (in Qt).
For me, the first question is, which technologies do I need for this?
In my naivety I would now assume that the Qt program for generating data would have to run on a server with a fixed IP. It would also have to be able to connect via sockets.
The website would use a PHP script running on a web server, so that it would somehow communicate with the Qt program?
Thanks a lot for any help!
|
|
|
|
|
hello all alone,
The C ++ executable application under Qt must save its data produced in a BDD Database
(or a file) on the web server side; and the web application (also running on the server), called
by the remote client web browser, will read these data in the DB (or in the file) for then
interpret / decode them then display them as graphics in the client browser.
For example in PHP, there are functions to access the mySQL database.
Under Qt, you can also access mySQL databases in C ++.
Other solutions :
- use (or design) a suitable PHP extension,
- call the executable C ++ program from PHP with the PHP function shell_exec ()
( see an example of "Serial COM port access in PHP" here:
https://radiovibrations.com/techblog.php?i=10 )
Cordially.
|
|
|
|
|
Hi All,
I am using Kendo Grid in my application and need to implement better paging feature, sorting, Filtering,Groping and customization. Please share if anyone as implemented this feature already.
Thanks,
Sagar Pallavi
|
|
|
|
|
Hi Everyone, I'm new here
|
|
|
|
|
|
Hello,
I am looking for software where I can code and alter my Wordpress site. Using a mac, tried Adobe Dreamweaver, didnt get far. Recommandations please? Thank you in advance!
|
|
|
|
|
|
Why do we need them? What can't I just do this:
public class MyController : ApiController
{
public void DoSomething(MyEntity entity)
{
MyBL myBL = new MyBL();
myBl.DoSomethingElse(entity);
}
}
Why do I need the Http verbs to do this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You generally want to avoid letting GET requests modify state. They should be idempotent to avoid problems with pre-fetching and caching.
Beyond that, you can use whatever verbs you like. But REST services follow a specific pattern:
Representational state transfer - Wikipedia[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK. So said anything about state? What's stopping me from doing this:
public class MyController : ApiController
{
[HttpGet]
public void DoSomething(int id)
{
MyBL myBL = new MyBL();
myBl.DeleteARecord(Id);
}
}
I'm calling a method to delete a record in a method marked as [HttpGet].
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
As I said, you should avoid doing that. Your GET method could be called multiple times. It could be pre-fetched. It could be cached.
GET requests should be idempotent, and should not affect state.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Every http request has a verb, that's just how http works, the verb lets the service know what action is being done, the theory being that you can use the same url to do different things. If you have the following endpoint
/product/5
then calling it with GET will return product 5's data, calling it with DELETE will delete product 5 and so on. Because all requests have a verb you have to tell .net which verbs are valid for your method.
|
|
|
|
|
I guess I don't understand why you even need to mark up the method. What if I did this:
public class MyController : ApiController
{
[HttpGet]
public void DoSomething(int id)
{
MyBL myBL = new MyBL();
myBl.DeleteARecord(Id);
}
}
I've marked the method with [HttpGet], yet called a Delete method on the BL.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
If you do that it will fail with a 404 as the method doesn't allow that verb.
|
|
|
|
|
Why not? There's nothing there to indicate what is does. I could name the BL method "BeHappy" and it would still run
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
It won't work because you haven't marked it [HttpDelete]
|
|
|
|