Skip to main content

Posts

Showing posts with the label c#

Store Data in to Micro-Services Static class using c# dot net core (Key Based API for Reduce Database hit)

Find Code From Here :  Code Testing : 1. 1st Time Entry with Null key value and Adding New Value into Class Testing : 2 . 2nd Time Entry with unique key value and updating existing entry into Class Testing : 3. Same Time Another Hit Came From different User for for update Data  Testing 4: If Step is 4 then we are inserting data into our database and Deleting data from class using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace AppForStaticCls.Controllers {     [Route("api/[controller]")]     public class MutiplePostController : Controller     {         // GET: api/<controller>         [HttpGet]         public IEnumerab...

Redirect to login screen if session is expired in Asp.net c# (Web Form)

Follow bellow code in global.asax protected void Application_AcquireRequestState( object sender, EventArgs e)         {             try             {                 string lcReqPath = Request.Path.ToLower();                 // Session is not stable in AcquireRequestState - Use Current.Session instead.                 System.Web.SessionState. HttpSessionState curSession = HttpContext .Current.Session;                  if (lcReqPath != "/root/login.aspx" && (curSession == null || curSession[ "User_Type" ] == null )...

Extension Method In C#

using System; namespace ExtensionMethod { public class Program { public static void Main( string [] args) { string str= "Hello World" ; int i= 0 ; //Normal Method WithouExtCls witCl= new WithouExtCls (); i= witCl.extCharCount( "test abce" ); Console.WriteLine(i) ; //Ext Method use as normal method Console.WriteLine(ExtensionMethodCls.extCharCount( "test" )); //Ext Method for string i=str.extCharCount(); Console.WriteLine(i); } } public static class ExtensionMethodCls { public static int extCharCount( this string strChar) { return strChar.Length; } } public class WithouExtCls { public int extCharCount( string str) { return str.Length; } } }

Pass HTML Element in Asp.net Label dynamically

Hi Techies, Sometimes we need dynamic multiple HTML Tag inside server side control like "Label". So in this case we are doing following type code. ASPX Page   <asp:Label ID="lblText" Text="Test" runat="server"></asp:Label> CS.             lblText.Text += "<label> Hi </label> ";             lblText.Text += "<br />";             lblText.Text += "<br />"; Thanks