Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home5/programz/hyperbytelabs.com/wp-content/plugins/revslider/includes/operations.class.php on line 2715

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home5/programz/hyperbytelabs.com/wp-content/plugins/revslider/includes/operations.class.php on line 2719

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home5/programz/hyperbytelabs.com/wp-content/plugins/revslider/includes/output.class.php on line 3615
ASP.Net Archives - Hyper Byte Labs https://hyperbytelabs.com/category/asp-net/ Solutions Start Here Sun, 06 Mar 2022 22:16:05 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.3 https://hyperbytelabs.com/wp-content/uploads/2019/01/cropped-HBLizSmall-32x32.png ASP.Net Archives - Hyper Byte Labs https://hyperbytelabs.com/category/asp-net/ 32 32 Cast Object to T https://hyperbytelabs.com/cast-object-to-t/?utm_source=rss&utm_medium=rss&utm_campaign=cast-object-to-t https://hyperbytelabs.com/cast-object-to-t/#respond Sun, 06 Mar 2022 22:15:45 +0000 https://hyperbytelabs.com/?p=4393 First test to see if the object is a castable class if that doesn’t work for basic types int string etc then you will use Convert.ChangeType..

The post Cast Object to T appeared first on Hyper Byte Labs.

]]>
First test to see if the object is a castable class if that doesn’t work for basic types int string etc then you will use Convert.ChangeType..

if (readData is T) {
    return (T)readData;
} 
try {
   return (T)Convert.ChangeType(readData, typeof(T));
} 
catch (InvalidCastException) {
   return default(T);
}

The post Cast Object to T appeared first on Hyper Byte Labs.

]]>
https://hyperbytelabs.com/cast-object-to-t/feed/ 0
ASP.Net C# Clean Exit to Exit Web Application Without Errors https://hyperbytelabs.com/asp-net-c-clean-exit-to-exit-web-application-without-errors/?utm_source=rss&utm_medium=rss&utm_campaign=asp-net-c-clean-exit-to-exit-web-application-without-errors Wed, 23 Jun 2021 19:13:08 +0000 https://hyperbytelabs.com/?p=4383 The post ASP.Net C# Clean Exit to Exit Web Application Without Errors appeared first on Hyper Byte Labs.

]]>
public static void CleanExit(string reponseText = null) { if (String.IsNullOrEmpty(reponseText) == false) { HttpContext.Current.Response.Write(reponseText); } try { //Sends the response buffer HttpContext.Current.Response.Flush(); // Prevents any other content from being sent to the browser HttpContext.Current.Response.SuppressContent = true; //Directs the thread to finish, bypassing additional processing HttpContext.Current.ApplicationInstance.CompleteRequest(); //Suspends the current thread Thread.Sleep(1); } catch { } finally { } }

The post ASP.Net C# Clean Exit to Exit Web Application Without Errors appeared first on Hyper Byte Labs.

]]>
C# Base URL or Current Page URL https://hyperbytelabs.com/c-base-url-or-current-page-url/?utm_source=rss&utm_medium=rss&utm_campaign=c-base-url-or-current-page-url Wed, 23 Jun 2021 19:08:06 +0000 https://hyperbytelabs.com/?p=4381 The post C# Base URL or Current Page URL appeared first on Hyper Byte Labs.

]]>
//Full URL string url = HttpContext.Current.Request.Url.ToString(); // http://localhost:1234/test/test.aspx?cool=true string url = HttpContext.Current.Request.Url.AbsoluteUri; // http://localhost:1234/test/test.aspx string path = HttpContext.Current.Request.Url.AbsolutePath; // /test/test.aspx string host = HttpContext.Current.Request.Url.Host; // localhost Here it is in a function: public enum URLType { Full, URI, Path, Host } public static string GetCurrentURL(URLType type = URLType.Full) { switch (type) { case URLType.URI: return HttpContext.Current.Request.Url.AbsoluteUri; case URLType.Path: return HttpContext.Current.Request.Url.AbsolutePath; case URLType.Host: return HttpContext.Current.Request.Url.Host + (HttpContext.Current.Request.Url.IsDefaultPort ? "" : ":" + HttpContext.Current.Request.Url.Port); default: case URLType.Full: return HttpContext.Current.Request.Url.ToString(); } }

The post C# Base URL or Current Page URL appeared first on Hyper Byte Labs.

]]>
JavaScript StartsWith / EndsWith https://hyperbytelabs.com/javascript-startswith-endswith/?utm_source=rss&utm_medium=rss&utm_campaign=javascript-startswith-endswith Sun, 10 Nov 2019 07:22:44 +0000 https://hyperbytelabs.com/?p=4345 The post JavaScript StartsWith / EndsWith appeared first on Hyper Byte Labs.

]]>
The post JavaScript StartsWith / EndsWith appeared first on Hyper Byte Labs.

]]>
C# IsNullOrEmpty for all objects https://hyperbytelabs.com/c-isnullorempty-for-all-objects/?utm_source=rss&utm_medium=rss&utm_campaign=c-isnullorempty-for-all-objects Wed, 30 Oct 2019 03:35:47 +0000 https://hyperbytelabs.com/?p=4328 The post C# IsNullOrEmpty for all objects appeared first on Hyper Byte Labs.

]]>
The post C# IsNullOrEmpty for all objects appeared first on Hyper Byte Labs.

]]>
C# Test for Basic Type https://hyperbytelabs.com/c-test-for-basic-type/?utm_source=rss&utm_medium=rss&utm_campaign=c-test-for-basic-type Wed, 30 Oct 2019 02:11:24 +0000 https://hyperbytelabs.com/?p=4302 The post C# Test for Basic Type appeared first on Hyper Byte Labs.

]]>
The post C# Test for Basic Type appeared first on Hyper Byte Labs.

]]>
C# Basic Object Types https://hyperbytelabs.com/c-basic-object-types/?utm_source=rss&utm_medium=rss&utm_campaign=c-basic-object-types Tue, 29 Oct 2019 22:19:35 +0000 https://hyperbytelabs.com/?p=4291 The post C# Basic Object Types appeared first on Hyper Byte Labs.

]]>
The post C# Basic Object Types appeared first on Hyper Byte Labs.

]]>