c#
ASP.NET Core MVC Mixed Route/FromBody Model Binding & Validation
I am using ASP.NET Core 1.1 MVC to build an JSON API. Given the following model and action method:
Parse json string using JSON.NET
I have a string like the following in C#. I need to loop through and create an HTML table output. I tried with JSON.NET but couldn’t figure out how to retrieve the keys (Name, Age & Job).
ASP.NET Setting width of DataBound column in GridView
I have a GridView which uses BoundField for columns. I am trying to set a maxwidth for my UserInfo column.
Consuming a REST XML web service
I’m trying to consume the following web service http://ipinfodb.com/ip_location_api.php
this web service returns an xml response, the code below gets the XML response, but somehow when phasing the values from the XML response it does not work.
XmlDocument – load from string?
protected void Page_Load(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); try { string path = Server.MapPath("."); doc.Load(path+"whatever.xml"); } catch (Exception ex) { lblError.Text = ex.ToString(); return; } // Convert XML to a JSON string string JSON = XmlToJSON(doc); // Replace with \ because string is being decoded twice JSON = JSON.Replace(@"", @"\"); // … Read more
Checking login user role in razor page
@if (Request.IsAuthenticated && User.Identity.Name=="administrator") { <div id="sidebar"> <div class="module"> <ul class="menu"> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("About", "About", "Home")</li> <li>@Html.ActionLink("Contact", "Contact", "Home")</li> </ul> </div> <div class="mainContent"> Hello, @User.Identity.Name ! </div> </div> This is my layout if the user is authenticated as administrator but this sort of check looks no good, I need to check the role of … Read more
REST WCF service locks thread when called using AJAX in an ASP.Net site
I have a WCF REST service consumed in an ASP.Net site, from a page, using AJAX.
Passing int list as a parameter to a web user control
I want to pass an int list (List) as a declarative property to a web user control like this:
Mini MVC profiler: appears to be displaying profile times for every static resource
I’ve just started using the mvc-mini-profiler (http://code.google.com/p/mvc-mini-profiler/) and I think it’s awesome. However, I’m getting some odd behaviour while using it.