Click here to Skip to main content
15,878,602 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: CSS background(url) not working Pin
Member 1497619926-Oct-20 22:30
Member 1497619926-Oct-20 22:30 
QuestionChanging documentroot in Apache http.conf file causes PHP to stop working Pin
MontanaMan9-Oct-20 16:58
MontanaMan9-Oct-20 16:58 
AnswerRe: Changing documentroot in Apache http.conf file causes PHP to stop working Pin
Graham Breach9-Oct-20 22:14
Graham Breach9-Oct-20 22:14 
GeneralRe: Changing documentroot in Apache http.conf file causes PHP to stop working Pin
MontanaMan10-Oct-20 3:18
MontanaMan10-Oct-20 3:18 
Questionadding colors css file? Pin
auting826-Oct-20 5:24
auting826-Oct-20 5:24 
AnswerRe: adding colors css file? Pin
Richard MacCutchan9-Oct-20 21:59
mveRichard MacCutchan9-Oct-20 21:59 
AnswerRe: adding colors css file? Pin
W Balboos, GHB10-Nov-20 4:34
W Balboos, GHB10-Nov-20 4:34 
QuestionASP.net Web API Errors Pin
Kevin Marois29-Sep-20 10:53
professionalKevin Marois29-Sep-20 10:53 
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.

AnswerRe: ASP.net Web API Errors Pin
Afzaal Ahmad Zeeshan29-Sep-20 11:20
professionalAfzaal Ahmad Zeeshan29-Sep-20 11:20 
GeneralRe: ASP.net Web API Errors Pin
Kevin Marois29-Sep-20 11:28
professionalKevin Marois29-Sep-20 11:28 
AnswerRe: ASP.net Web API Errors Pin
Richard Deeming29-Sep-20 21:27
mveRichard Deeming29-Sep-20 21:27 
GeneralRe: ASP.net Web API Errors Pin
Kevin Marois30-Sep-20 5:48
professionalKevin Marois30-Sep-20 5:48 
GeneralRe: ASP.net Web API Errors Pin
Richard Deeming30-Sep-20 6:50
mveRichard Deeming30-Sep-20 6:50 
NewsCoding multiple text blocks over a single image in HTML Pin
Member 1495060328-Sep-20 5:40
Member 1495060328-Sep-20 5:40 
Questionhello! 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 Pin
Member 1493949715-Sep-20 20:56
Member 1493949715-Sep-20 20:56 
AnswerRe: hello! 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 Pin
Richard MacCutchan15-Sep-20 21:34
mveRichard MacCutchan15-Sep-20 21:34 
Answerok, thanks Pin
Member 1493949715-Sep-20 21:39
Member 1493949715-Sep-20 21:39 
SuggestionRe: Domain registration Pin
Richard Deeming15-Sep-20 22:01
mveRichard Deeming15-Sep-20 22:01 
Questionvisualization of data on a website, where the data is provided by some remote C++ program Pin
Arist0tle11-Sep-20 5:44
Arist0tle11-Sep-20 5:44 
AnswerRe: visualization of data on a website, where the data is provided by some remote C++ program Pin
professor tourneseul17-Mar-21 7:50
professor tourneseul17-Mar-21 7:50 
QuestionKENDO GRID with PAGING, SORTING, FILTERING , CUSTOMIZATION Pin
sagarpallavi9-Sep-20 21:40
sagarpallavi9-Sep-20 21:40 
QuestionHI Everyone Pin
Sarbjit Grewal6-Sep-20 18:20
professionalSarbjit Grewal6-Sep-20 18:20 
AnswerRe: HI Everyone Pin
Sandeep Mewara6-Sep-20 19:03
mveSandeep Mewara6-Sep-20 19:03 
QuestionWordpress to html software, So I can code it freely (live option?) Pin
Dr3am'R6-Sep-20 4:58
Dr3am'R6-Sep-20 4:58 
AnswerRe: Wordpress to html software, So I can code it freely (live option?) Pin
Sandeep Mewara6-Sep-20 19:07
mveSandeep Mewara6-Sep-20 19:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.