machine.config
record is the master configuration document on your framework with a lot of default settings.And Web.config
is the file for the local settings to be applied for a website which store configuration information in XML format.Machine.config
file are applied to the entire asp.net
applications on your server while the settings made in the Web.config
file are applied to that specific web application only.machine.config
file, simultaneously, each web application has its own web.config
file. Directories inside a web application can have web.config files as well.machine.config
case you should restart the application.c:\windows\microsoft.net\framework\version\config
folder whereas web.config will automatically be made when you make an ASP.Net
web application project.Machine.config
is the design configuration file for all the applications in the IIS, but Web. config is a configuration file for a specific application. public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<TestClass>();
}
Grid View, | DataGrid |
---|---|
It was introduced with Asp.Net 2.0. | It was introduced with Asp.Net 1.0. |
Built-in supports for Paging and Sorting. | For sorting you need to handle SortCommand event and rebind grid required and for paging, you need to handle the PageIndexChanged event and rebind grid required., |
Built-in supports for Update and Delete operations. | Need to write code for implementing Update and Delete operations. |
Supports auto-format or style features. | This feature is not supported. |
Performance is slow as compared to DataGrid | Performance is fast as compared to GridView. |
User Control | Custom Control |
---|---|
User controls are created just like a web form. They make use of the existing controls to define their own logic. | A custom control is one that is made or created by the programmer to serve the business needs, by extending the functionality of existing controls. |
We can User control easily. | The creation of custom control is not easy as compare to user control |
These control do not run on their own dll. | While these control can run on their own dl. |
We can not add to the toolbox. | While we can add to the toolbox.we |
This control is not flexible. | This control is more flexible. |
Once we created a single copy of this control, we can use this copy to different projects as well. | We can not call or use a single copy of this control in different applications. For this, we need to create a control for each and every application. |
Repeater | ListView |
---|---|
Flexible layout introduced in .NET 1.0. | Flexible layout with easy customization introduced with .NET 3.5 |
No built-in support, custom code should be written for data grouping and paging. | Provides built-in support for data grouping and paging. |
Update, insert, delete and sorting operations are not supported. | All the operations are supported. |
Offers better performance. | Slower performance compared to a repeater. |
Local Resources | Global Resources |
---|---|
A local resource can only be accessed by the page that created it. | Accessible by all pages. |
Difficult to maintain when the website has a lot of localized content as each page requires a resource file for each language. | Only one file per language is required. |
Stored in the App_LocalResources folder. | Stored in the App_GlobalResources folder. |
ASP.NET
Server Control is capable of exposing an object model containing properties, methods, and events. This object model can be utilized by the ASP.NET developers to modify and interact with the Web page. Web controls contain all basic controls of HTML controls as well as some new controls like as DataGrid, DataList, and Calendar.WEB CONTROL | DESCRIPTION |
---|---|
Label | Represents a label control |
ListBox | Represents a list box control |
CheckBox | Represents a Check box control |
Calendar | Represents a calendar control |
ImageButton | Represents an image button control |
TableCell | Represents a table cell |
Panel | Represents a panel control |
DataList | Represents a data list control |
TextBox | Represents a text box control |
Image | Represents an image control |
CheckBoxList | Represents a list box with checkboxes |
Button | Represents a button control |
HyperLink | Represents a hyperlink control |
TableRow | Represents a row of a table |
RadioButtonList | Represents a list box with radio button controls |
DataGrid | Represents a data grid control |
DropDownList | Represents a drop-down list control |
AdRotator | Represents an ad rotator control |
RadioButton | Represents a radio button control |
LinkButton | Represents a link button control |
Table | Represents a table control |
Repeater | Represents a repeater control |
public class MyAppDomain: MarshalByRefObject
{
public string GetInfo()
{
return AppDomain.CurrentDomain.FriendlyName;
}
}
public class MyApp
{
public static void Main()
{
AppDomain apd = AppDomain.CreateDomain("Rajendrs Domain");
MyAppDomain apdinfo = (MyAppDomain) apd.CreateInstanceAndUnwrap(Assembly.GetCallingAssembly(
)
.GetName()
.Name, "MyAppDomain");
Console.WriteLine("Application Name = " + apdinfo.GetInfo());
}
}
String Request.QueryString(variable)[(index).count]
Transfer.REST
is an architectural style that doesn’t follow any strict standard but follows six constraints defined by Roy Fielding in 2000. Those constraints are – Uniform Interface, Client-Server, Stateless, Cacheable, Layered System, Code on Demand.REST is not restricted to XML and it’s the choice of implementer which Media-Type to use like XML, JSON, Plain-text. Moreover, REST can use SOAP protocol but SOAP cannot use REST.REST
is easy to implement and requires less bandwidth such as smartphones..csproj
file. If you have worked with JavaScript before, think of it like a package.json
file. The difference is, instead of a JSON, this is an XML file..NET
tooling needs to build the project. It includes the type of project you are building (console, web, desktop, etc.
), the platform this project targets, and any dependencies on other projects or 3rd party libraries
..csproj
file that lists the Nuget packages and their specific versions. <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="3.5.6.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Npgsql" Version="5.0.1.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
</ItemGroup>
</Project>
Newtonsoft.Json
is a very popular package (with 91,528,205 downloads at the time of writing) used to work with JSON data in .NET. HTTP
request (the next question explains the concept of Middleware in detail).ConfigureServices()
and Configure().
As the name suggests, the first method registers all the services that the application needs. The second method configures the middleware pipeline.Appsettings.json
contains all of the application's settings, which allow you to configure your application behavior.appsettings.json
file.{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ConnectionStrings": {
"AppConnection": ""
},
"AWS": {
"Profile": "local-test-profile",
"Region": "us-west-2"
},
"AllowedHosts": "*"
}
[HttpGet("posts/{id}")]
public ActionResult<Post> GetById(int id, bool archivedOnly)
http://yourapp.com/api/Posts/5?ArchivedOnly=true
public class HomeController : Controller
{
public IActionResult About()
{
var pathBase = HttpContext.Request.PathBase;
...
return View();
}
}
Configure()
method in the Startup.cs class contains the following code that sets up the conventional routing.app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
{controller=Home}/{action=Index}/{id?}
’ is used to match an incoming URL such as /Posts/Archived/5 to the Archived(int id) action method on the PostsController, passing 5 for the id parameter. By default, the router uses the Index method on the HomeController. myapp.com/blog/post/3
to the Show method on the PostsController.[Route("blog")]
public class PostsController : Controller
{
[HttpGet("post/{id:int}")]
public IActionResult Show(int id = 0)
{
Post post = new Post()
{
ID = id
};
return View("Show", post);
}
[HttpGet("edit/{id:int}")]
public IActionResult Edit(int id)
{
Post postToEdit = _service.Get(id);
return View("Edit", postToEdit);
}
}
[Route(“blog”)]
is placed on the controller, whereas the route [HttpGet(“post/{id:int}”)]
is placed on the action method. A controller route applies to all actions in that controller. For example, the second [“edit/{id:int}”]
route matches the url myapp.com/blog/edit/3
.Response.Redirect("UserDetail.aspx");
Server.Transfer("UserDetail.aspx");
Web.Config
file.<sessionState>
tag under <system.web>
tag.cookieless
" in the <sessionState>
tag and set its value to "AutoDetect
" like below:
<sessionState cookieless="AutoDetect" regenerateExpiredSessionId="true"/>​
regenerateExpiredSessionId
" is used to ensure that if a cookieless url is expired a new new url is created with a new session. And if the same cookieless url is being used by multiple users an the same time, they all get a new regenerated session url. For further info click on the link,