.Net Interview Questions
Open in Telegram
1 794
Subscribers
+124 hours
+207 days
+4930 days
Posts Archive
1. Use regular expressions
2. Use an object that implements IRouteConstraint interface
Use a route with a catch-all parameter. An example is shown below. * is referred to as catch-all parameter.
controller/{action}/{*parametervalues}
✅2️⃣0️⃣7️⃣ How do you handle variable number of segments in a route definition?
To add routes to a webforms application, we use MapPageRoute() method of the RouteCollection class, where as to add routes to an MVC application we use MapRoute() method.
✅2️⃣0️⃣6️⃣ What is the difference between adding routes, to a webforms application and to an mvc application?
This route definition, prevent requests for the Web resource files such as WebResource.axd or ScriptResource.axd from being passed to a controller.
✅2️⃣0️⃣5️⃣ What is the use of the following default route?
{resource}.axd/{*pathInfo}
{controller}{action}/{id}
No, the above definition is not a valid route definition, because there is no literal value or delimiter between the placeholders. Therefore, routing cannot determine where to separate the value for the controller placeholder from the value for the action placeholder.
1. URL Pattern - You can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string.
2. Handler - The handler can be a physical file such as an .aspx file or a controller class.
3. Name for the Route - Name is optional.
In an ASP.NET web application that does not make use of routing, an incoming browser request should map to a physical file. If the file does not exist, we get page not found error.
An ASP.NET web application that does make use of routing, makes use of URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.
