|
When you set a color or background-color style it applies to the items contained in that element.
Your entire page is a <body> element and so if you change the color at that level the entire page is effected. Now if you create an element within the body, like a <div>, you can control it's styles by putting them in that div. It will then not be spread to the entire page.
OK - now the only thing left for you to do. If you want the top of the page to be one color and the rest of the page to not be affected, you can put that div element at the top of the page. Color it. Put text in it. Put images in it. Anything you want.
It's actually extremely common (probably why you want to do it) - becomes a page header, visually.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I'm creating a RestSharp wrapper class. I'm trying to test it with a simple controller. I'm getting some errors.
RestSharp Wrapper
public class RestSharpProxy
{
#region Private Fields
private RestClient _client;
private RestRequest _request;
#endregion
#region Properties
public ServerInfo ServerInfo { get; private set; }
#endregion
#region CTOR
public RestSharpProxy(ServerInfo serverInfo, string action, Method method = Method.GET)
{
ServerInfo = serverInfo;
_client = new RestClient(serverInfo.ServerURL)
{
Authenticator = new HttpBasicAuthenticator(serverInfo.UserName, serverInfo.Password)
};
_request = new RestRequest(action, method)
{
RequestFormat = RestSharp.DataFormat.Json
};
}
#endregion
#region Public Methods
public void AddParameter(object arg)
{
_request.AddJsonBody(arg);
}
public void AddParameter(string name, object arg)
{
_request.AddParameter(name, arg);
}
public async Task ExecuteAsync()
{
IRestResponse response = await _client.ExecuteAsync(_request, new CancellationToken());
if (response.ResponseStatus != ResponseStatus.Completed ||
response.StatusCode != System.Net.HttpStatusCode.OK)
{
throw new Exception($"API Error: {response.StatusCode} - {response.ErrorMessage}");
}
}
public async Task<T> ExecuteAsync<T>()
{
IRestResponse<T> response = await _client.ExecuteAsync<T>(_request, new CancellationToken());
if (response.ResponseStatus != ResponseStatus.Completed ||
response.StatusCode != System.Net.HttpStatusCode.OK)
{
throw new Exception($"API Error: {response.StatusCode} - {response.Content}");
}
var results = JsonConvert.DeserializeObject<T>(response.Content);
return results;
}
#endregion
}
Controller
public class CustomerController : ApiController
{
[HttpGet]
public List<CustomerEntity> GetAll()
{
var results = new List<CustomerEntity>
{
new CustomerEntity { Id = 1, CustomerName = "John Smith"},
new CustomerEntity { Id = 2, CustomerName = "William Dover"},
};
return results;
}
[HttpGet]
public CustomerEntity Get(int id)
{
return new CustomerEntity { Id = id, CustomerName = "Amber Stone" };
}
[HttpGet]
public int GetAnInt()
{
return 100;
}
[HttpPost]
public void Add([FromBody] CustomerEntity customer)
{
}
[HttpPost]
public void SendSomeString([FromBody] string value)
{
}
[HttpPost]
public void Update([FromBody] CustomerEntity customer)
{
}
[HttpDelete]
public void Delete(int id)
{
}
}
Issues
Any controller method I call that returns something, like all 3 Get methods, work fine. For any methods that return void I get back "No Content". In all cases the RsponseStatus is Completed.
What am I doing wrong here?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Quote: What am I doing wrong here? You are not returning anything from the controller, hence the "No Content" is being shown on the client-side.
If you want to see something, try returning that value from the controller instead. For example, in your Delete method, return a string stating that the object has been deleted.
[HttpDelete]
public string Delete(int id)
{
return $"Object with ID {id} has been deleted.";
} Now, this should return a string value. Similarly, modify other methods as well so they also return a proper response instead of a void telling the browser to not print anything.
With an API, you are able to return complex objects as well and the API will automatically serialize the results in a JSON document format that can be used on the client-side to provide a clear response.
Please see these two tutorials:
How do I get ASP.NET Web API to return JSON instead of XML using Chrome? - Stack Overflow
Format response data in ASP.NET Core Web API | Microsoft Docs
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
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.
|
|
|
|