Issues and fixes from office

How to get value in the session in jQuery


You can't access session variables directly from jQuery: Sessions run on the server; JavaScript runs on the client.



----------------------------------------------------

How to add Pagination in .net


--------------------------------------

How to read the headers value in .net core 6 using httpclient

 using (var client = new HttpClient())
        {
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", HttpContext.Session.GetString("JwtToken"));            

            var url = $"https://api.test.osmsinc.com/api/transactions";            

            var requestUri = new Uri(url);

            var responseTask = client.GetAsync(requestUri);
            responseTask.Wait();
            var result = responseTask.Result;
           
            TotalResults = result.Headers.GetValues("X-TotalResults");

            if (result.IsSuccessStatusCode)
            {
                var reportResults = Task.Run(async() => await result.Content.ReadAsAsync<JArray>()).Result;                  
                return reportResults;
            }
        }

------------------------------------------------------

* How to read a json property which has a space

 @Model.Transactions["custom_data"]["Form Response"]

https://stackoverflow.com/questions/72684150/how-to-read-a-json-key-which-has-space-in-c-sharp


---------------------------------

* how to pass jobject to cshtml

store Jobject into dynamic 

then use it in .cshtml

-----------------------------------

* Exception has occurred: CLR/System.AggregateException

An exception of type 'System.AggregateException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'One or more errors occurred.'

 Inner exceptions found, see $exception in variables window for more details.

 Innermost exception   Newtonsoft.Json.JsonSerializationException : Deserialized JSON type 'Newtonsoft.Json.Linq.JObject' is not compatible with expected type 'Newtonsoft.Json.Linq.JArray


- ChangedJArray  to  JObject 


------------------------------------

 * Exception has occurred: CLR/System.AggregateException

An exception of type 'System.AggregateException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'One or more errors occurred.'

 Inner exceptions found, see $exception in variables window for more details.

 Innermost exception Newtonsoft.Json.JsonSerializationException : Deserialized JSON type 'Newtonsoft.Json.Linq.JArray' is not compatible with expected type 'Newtonsoft.Json.Linq.JObject'. Path '', line 1, position 68009.


- Changed JObject to JArray

-------------------------------------------------

* 'HttpContent' does not contain a definition for 'ReadAsAsync' and no accessible

Make sure that you have installed the correct NuGet package in your console application:

<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" />

and that you are targeting at least .NET 4.0.

This being said, your GetAllFoos function is defined to return an IEnumerable<Prospect> whereas in your ReadAsAsync method you are passing IEnumerable<Foo> which obviously are not compatible types.

Install-Package Microsoft.AspNet.WebApi.Client

Select project in project manager console


----------------------------------------------------------



Comments

Popular Posts