Friday, May 17, 2024

What's the difference between protected and internal? What about "protected internal"?

 Protected

  • Definition: Think of protected as a family secret. Only you and your children know about it.
  • Example: Imagine you have a special recipe that you share only with your children. They can use it, but no one outside your family can.

Internal

  • Definition: Consider internal like company confidential information. Everyone in the company can see it, but no one outside the company can.
  • Example: Suppose you have an internal company document that all employees can read, but it is not shared with people outside the company.

Protected Internal

  • Definition: This is a combination of both concepts. It's like having a secret that you share with your family and anyone who works at the family business.
  • Example: You have a special recipe (protected) that you share with your children and also with any employees (internal) in your family-run restaurant.

Summary

  • Protected: Shared only within the family (you and your children).
  • Internal: Shared within the company (any employee).
  • Protected Internal: Shared with both family members and company employees.

Thursday, May 9, 2024

Process with an Id of #### is not running" in Visual Studio 2013 or etc

 The error message “Process with an Id of #### is not running” in Visual Studio can be quite frustrating, but there are several steps you can take to resolve it. Here are some solutions you can try:

  1. Delete the Hidden .vs Folder:

    • Close Visual Studio.
    • Navigate to the folder where your solution files are stored and delete the hidden .vs folder.
    • Restart Visual Studio.
    • Hit F5, and IIS Express should load as normal, allowing you to debug.
    • Note that this problem seems to be caused by moving a project between workstations, environments, or different versions of Visual Studio. The .vs folder may contain environment-specific information
  2. Edit the Project File:

    • Open Visual Studio as an administrator.
    • Right-click your project and select “Unload Project.”
    • Again, right-click your project and choose “Edit PROJECT_NAME.csproj.”
    • Find the following code and delete it:
      XML
      <DevelopmentServerPort>63366</DevelopmentServerPort>
      <DevelopmentServerVPath>/</DevelopmentServerVPath>
      <IISUrl>http://localhost:63366/</IISUrl>
      
    • Save and close the .csproj file.
    • Right-click your project and reload it1.
  3. Restart IIS Express:

    • Stop the application.
    • Make sure no other ASP.NET or Web API applications are running. If they are, stop them as well.
    • Open the Run dialog by pressing Windows Key + R.
    • Type iisreset in the textbox and press OK.
    • A command prompt window might open and perform some background processing. .
  4. Additional Solutions:

    • Delete the IIS folder with the following command:
      rmdir /s /q "%userprofile%\Documents\IISExpress"
      
    • Delete the .vsConfig folder in your Visual Studio instance.
    • Relaunch Visual Studio as an Administrator so that the necessary files can be rebuilt.

Tuesday, May 7, 2024

kill datebase session id

Use master

SELECT session_id, login_name, host_name, program_name

FROM sys.dm_exec_sessions

WHERE database_id = DB_ID('yourdatabasename');


KILL seesion Id(SSID);

Thursday, May 2, 2024

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

 public ActionResult GetDocumentCompData(string docId)

         {

             SessionValues sessionValues = new GetSessionValues();

             try

             {

                 ResponseModel response = ApiCalls.Get(GetApiUrls.GetDocumentInfo + "?documentId=" + docId);


                 if (response != null && response.Data != null)

                 {

                     DocumentsModel retval = JsonConvert.DeserializeObject<DocumentsModel>(response.Data.ToString());

                     retval.FileName = Path.GetFileName(retval.FileLocation);


                     // Serialize the DocumentsModel object to JSON and stream it directly to the response

                     var serializer = JsonSerializer.CreateDefault();

                     Response.BufferOutput = false; // Disable buffering to stream content

                     Response.ContentType = "application/json";


                     using (var streamWriter = new StreamWriter(Response.OutputStream))

                     using (var jsonWriter = new JsonTextWriter(streamWriter))

                     {

                         serializer.Serialize(jsonWriter, new { Data = retval, Message = response.Message, Status = response.Status });

                     }


                     // Ensure the response is complete

                     Response.Flush();

                     return new EmptyResult(); // Return an EmptyResult to indicate that the action has completed

                 }

             }

             catch (Exception e)

             {

                 bool rethrow = CommonException.HandleException(e, Enums_Constants.ControllerPolicy);

                 if (rethrow)

                     throw;

             }

             return Json("", JsonRequestBehavior.AllowGet);

         }

Monday, April 15, 2024

How do you reset the identity start value in SQL Server?

TRUNCATE TABLE YourTableName; -- Delete all records 

DBCC CHECKIDENT ('YourTableName', RESEED, 1); -- Reset identity column 

Wednesday, April 10, 2024

How do electricity charges work in Telangana?

 1.If your monthly consumption is less than 100 units:

  • The first 50 units will be charged at Rs. 1.95 per unit.
  • The remaining 50 units will be charged at Rs. 3.10 per unit.
  1. If your monthly consumption is between 100 and 200 units:
  • The first 100 units will be charged at Rs. 3.40 per unit.
  • The remaining 100 units will be charged at Rs. 4.80 per unit.
  1. If your monthly consumption exceeds 800 units:
  • The first 200 units will be charged at Rs. 5.10 per unit.
  • The next 100 units (201-300) will be charged at Rs. 7.70 per unit.
  • The next 100 units (301-400) will be charged at Rs. 9.00 per unit.
  • The next 400 units will be charged at Rs. 9.50 per unit.
  • Any remaining units beyond 800 will be charged at Rs. 10.00 per unit.

Friday, March 22, 2024

What is the difference between Public, Static, void?

1. **Public**:

   - `Public` is an access modifier in programming languages like Java or C#. It means that a method or variable can be accessed from anywhere in the program. It's like leaving the door open for anyone to use.

2. **Static**:

   - `Static` is a keyword that means something belongs to the class itself, not to instances of the class. It's like a shared resource that all instances of the class can access. You don't need an object to use it.

3. **void**:

   - `void` is a keyword used in method declarations to indicate that the method doesn't return anything. It's like a promise that the method will do something, but it won't give you anything back.

**Example** (in Java or C# ):

public class Example {

    public static void greet() {

        System.out.println("Hello, world!"); // Printing a greeting

    }

    public static void main(String[] args) {

        greet(); // Calling the greet method

    }

}

Explanation:

- `public`: This means that the `greet` method can be accessed from anywhere in the program.

- `static`: This means that the `greet` method belongs to the class itself, not to any particular instance of the class.

- `void`: This means that the `greet` method doesn't return anything. It just prints "Hello, world!" to the console when it's called.

So, when we call `greet()` in the `main` method, it prints "Hello, world!" to the console, but it doesn't return any value.

What is hoisting in JavaScript?

**Hoisting in JavaScript**:

Hoisting is like when you magically lift things up. In JavaScript, it means that declarations (like variables and functions) are lifted or brought to the top of their scope during the code execution. 

**Example**:

console.log(x); // Output: undefined

var x = 10;

Explanation:

Even though we're trying to `console.log(x)` before declaring `x`, JavaScript doesn't give an error. Instead, it "hoists" the declaration of `x` to the top, which means it's like saying `var x;` is moved to the very top of the scope:

var x;

console.log(x); // Output: undefined

x = 10;

So, when we `console.log(x)` before assigning `x` a value, it outputs `undefined` because `x` exists (it's been declared), but it hasn't been assigned a value yet.

What is the difference between let and var in JavaScript?

**Scope:**

   - `let`: Variables declared with `let` are limited to the block they are declared in. They are only accessible within the block of code where they are defined.

   - `var`: Variables declared with `var` are function-scoped or globally scoped. They are accessible throughout the entire function where they are defined, or globally if not within a function.


// Using let

function letExample() {

    let x = 10;

    if (true) {

        let y = 20;

        console.log(x); // Output: 10

        console.log(y); // Output: 20

    }

    console.log(x); // Output: 10

    console.log(y); // ReferenceError: y is not defined

}

letExample();

// Using var

function varExample() {

    var x = 10;

    if (true) {

        var y = 20;

        console.log(x); // Output: 10

        console.log(y); // Output: 20

    }

    console.log(x); // Output: 10

    console.log(y); // Output: 20 (accessible due to var's function scope)

}

varExample();


In the `letExample`, `x` is accessible within the function `letExample`, but `y` is only accessible within the `if` block where it's defined. Trying to access `y` outside the `if` block will result in a `ReferenceError`.


In the `varExample`, both `x` and `y` are accessible within the entire `varExample` function, even though `y` is defined inside the `if` block. This is because variables declared with `var` are function-scoped.

Thursday, March 21, 2024

What is a LINQ query in C#?

 37. **What is a LINQ query in C#?**

    - A LINQ query is like asking a smart friend to find something for you from a big list. It's a way of asking the program to search, sort, or filter data in a flexible and easy-to-understand language.


38. **What is a tuple in C#?**

    - A tuple is like a mixed-up bag that can hold different types of things together. It's used to group multiple pieces of data into a single object.


39. **What is a CancellationToken in .NET Core?**

    - A CancellationToken is like a button you press to stop something from happening, even if it's already started. It's used to cancel tasks or operations in the program.


40. **What is a middleware in .NET Core?**

    - Middleware is like a helpful assistant that sits between the program and the outside world, handling requests and responses. It's used to add extra features or modify incoming and outgoing data.


41. **Difference between a repository and a service in .NET Core?**

    - A repository is like a specialized storehouse for data, while a service is like a helper that performs specific tasks for the program. Repositories deal with data storage and retrieval, while services handle business logic and application functionality.


42. **What is dependency injection in .NET Core?**

    - Dependency injection is like having a friend who brings you exactly what you need when you need it. It's a way of providing components or services to other parts of the program without them needing to know where those things come from.


43. **Difference between a singleton and a scoped service in .NET Core?**

    - A singleton service is like a shared resource that everyone in the program can use, while a scoped service is like a private resource that's only available to a specific part of the program. Singleton services are shared across the whole application, while scoped services are limited to a particular scope or context.


44. **Purpose of the ASP.NET Core pipeline?**

    - The ASP.NET Core pipeline is like a series of checkpoints that requests and responses pass through in a web application. It's used to handle incoming requests, process them, and send back responses, with each step adding or modifying features of the application.


45. **What is a JWT token in .NET Core?**

    - A JWT (JSON Web Token) token is like a special pass that grants access to certain parts of a web application. It's used for authentication and authorization, allowing users to prove their identity and access protected resources.


46. **What is a CORS policy in .NET Core?**

    - A CORS (Cross-Origin Resource Sharing) policy is like a set of rules that determines which websites can access resources from a web application. It's used to control access to resources from different domains and prevent unauthorized access.


47. **Purpose of the appsettings.json file in .NET Core?**

    - The appsettings.json file is like a storage space for configuration settings in a .NET Core application. It's used to store things like database connection strings, API keys, and other settings that can be easily changed without modifying the code.


48. **Purpose of the Startup.cs file in .NET Core?**

    - The Startup.cs file is like the main planner and organizer of a .NET Core application. It's responsible for configuring services, middleware, and other components needed to run the application smoothly. It's usually the first file that's executed when the application starts up.


49. **Difference between .NET Framework and .NET Core?**

    - .NET Framework is like a traditional tool that works mainly on Windows computers, while .NET Core is like a newer, more versatile tool that works on different platforms like Windows, macOS, and Linux. .NET Core is also more lightweight, open-source, and modern compared to .NET Framework.


50. **Advantages of using .NET Core?**

    - Some advantages of using .NET Core include its ability to work on different platforms, its lightweight and modular nature, being open-source, improved performance, and better support for modern web development practices like microservices and containerization.