URL re-write and asp.net 3.5 webform - asp.net

how could i do advance url re-write in asp.net3.5. when we post question in stackoverflow then our question is listed as hyperlink like below one.
What is dependency injection?
when we click on link then a dynamic page is show. so i want know if there is a hyperlink which have href like http://mysite.com/130794/what-is-dependency-injection
actualy i want that when user click on above link then user will be redirect to page where url will be shown in address toolbar like http://mysite.com/130794/what-is-dependency-injection. how could i achieve it without touching IIS. how to write the code. please help me with small sample to understand better. thanks

Thomas, check out ASP.NET Routing.
In a nutshell, ASP.NET Routing is a library that was introduced in the .NET Framework 3.5 SP1 that decouples the URL from a physical file. It is used heavily in ASP.NET MVC, but can also be used in WebForms applications. I have authored an article that discusses how to use ASP.NET Routing in an ASP.NET 3.5 SP1 WebForms application: Using ASP.NET Routing Without ASP.NET MVC. It includes a complete working demo you can download and try out on your computer.
From the article:
ASP.NET Routing is a library that was introduced in the .NET Framework 3.5 SP1 that decouples the URL from a physical file; it is used extensively in ASP.NET MVC web applications. With ASP.NET Routing you, the developer, define routing rules that indicate what route patterns map to what physical files. For example, you might indicate that the URL Categories/CategoryName maps to the ShowProductsByCategory.aspx ASP.NET page, passing along the CategoryName portion of the URL. The ASP.NET page could then display the products for that category. With such a mapping, users could view products for the Beverages category by visiting www.yoursite.com/Categories/Beverages rather than visiting the more verbose and less readable www.yoursite.com/ShowProductsByCategory.aspx?CategoryID=1.
While ASP.NET MVC is a great way to get started with ASP.NET Routing, the good news is that these two systems are independent of one another. It's quite possible to use ASP.NET Routing in a traditional ASP.NET Web Forms application. This article shows how to get ASP.NET Routing up and running in a Web Forms application. Read on to learn more!
To use ASP.NET Routing you'll need to be using ASP.NET 3.5 SP1 or ASP.NET 4. In fact, there were a number of enhancements to ASP.NET Routing in ASP.NET 4 to make it easier to use in a WebForms application, so if you can upgrade to ASP.NET 4 that might be helpful.
Happy Programming!

Related

Does ASP.NET mean ASP.NET WebForms?

I have worked with ASP.NET MVC 5.0 and that is the only ASP* technology I have ever seen or worked with. I even searched on Goolge and got more confused.
For example in this book, what are they teaching? When they say ASP.NET, does it mean ASP.NET Web Forms?
Mainly my question is this: When I see ASP.NET , does it mean ASP.NET WebForms? ( Unless it is ASP.NET core or MVC, those two I know ) but I get confused between ASP.NET and ASP.NET WebForms?
Many years ago one time I dragged dropped some buttons and text boxes on a ASP.NET page, it was VS2003 :) I think, so was that ASP.NET WebForms and this book above is still the continuation of that one? Or we can use some sort of ASP.NET that is not WebForms or MVC or Core too?
ASP.NET is a technology which is developed by Microsoft. You use it 2 different ways which are ASP.NET Web Forms and ASP.NET MVC. These are pattern and they have changable usage for the user. They have many layer.
For easy example: https://www.tutorialspoint.com/asp.net/asp.net_introduction.htm That's All :))
ASP.NET is a framework for creating server side web applications so it's set of tools , API , libraries ...etc , web forms is just part from this framework , other parts include ASP.NET MVC, ASP.NET Web Pages, and ASP.NET Single Page Applications.
check this :
https://www.asp.net/web-forms/what-is-web-forms
If we turned back the time, ASP.NET was of course WebForms initially in 2001, so we don't even need to explicitly call it WebForms.
The meaning of ASP.NET only changed when Microsoft published ASP.NET MVC (and later Web API/SignalR/Web Pages), some time around 2010. From then on ASP.NET is the umbrella term to cover them all, as well as WebForms.
Recently ASP.NET Core was created as a brand new platform, different from all previous frameworks. Thus, IMHO ASP.NET Core != ASP.NET.
Back to the book cover, it should mean all things under ASP.NET 4.5, which includes WebForms/MVC/Web API/SignalR/Web Pages.
I actually have that textbook and the author presents the material using ASP.NET WebForms. I believe he covers MVC but in short detail; I can't remember offhand.
As for the other answers, yes, ASP.NET is Microsoft's web programming framework. There are basically three primary technologies that you can leverage: ASP.NET MVC, ASP.NET Web API (actually an extension of ASP.NET MVC), and ASP.NET WebForms. You can of course create other types of apps as well, such as SPAs, but these are definitely the primary technologies available to you. The nice thing about these is that you aren't necessarily tied to one technology - you can mix and match different technologies in one solution.
If you are completely new to ASP.NET, I would suggest you look at Microsoft's tutorials on building ASP.NET Core applications so you can leverage the cross-platform technologies Microsoft is heading towards. You mentioned that you've worked with ASP.NET MVC and .NET Core, so I'm assuming you're also aware that you can leverage ASP.NET Web API there as well.
https://learn.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro
Hope that helps.

Merge MVC development in existing Asp.net Application

I want to one help
I have 1 Webform application which is in the Asp.Net and it is working fine and now I want to develop new functionality in Asp.Net MVC and merge in existing application.
So please provide any tutorial or any link which provide information for merging MVC functionality in existing Asp.Net application.
Basically I need to develop application which working with both Asp.net webform functionality and also MVC functionality.
Combining web forms with MVC is entirely possible. See this blog post by Scott Hanselman for an introduction.
Sharing master pages: see this StackOverflow question
routing: In ASP.Net 4.0, routing has been enabled for web forms page routes (scottgu's blog)

How Web page is a programming model to create ASP.Net web application

ASP.NET Web Forms is a part of the ASP.NET web application framework. It is one of the three different programming models you can use to create ASP.NET web applications, the others being ASP.NET MVC and ASP.NET Web Pages.
I have read above lines in asp.net site. My understanding is A web page may refer to a html document retrieved from server and A Web Form is a thing in ASP.NET Application used to generate a HTML document(in dynamic manner)
But definition of web forms said by asp.net site confused me. OK I can understand MVC is a programming model used to create ASP.NET Web application.
What is a Web Form ? and What is a Web page ?
How Web page is a programming model to create ASP.Net web application
ASP.Net is Microsoft's technology stack for building dynamic web sites.
Within that stack, they support 3 different ways of generating a web page.
Web Forms is the oldest - it's been around since ASP.Net was born. It's tightly coupled into Visual Studio, and has "drag and drop" page building. Most people who care about how their HTML is constructed dislike Web Forms, because the "drag and drop" components can make it hard to generate semantic, valid HTML - though the latest version is a lot better.
ASP.Net MVC is an alternative to Web Forms - and it's a pretty decent MVC framework.
Web Pages is another alternative; it's more of a scripting/templating solution, similar to PHP. It doesn't have the overhead/safetynet of a proper framework behind it (like MVC), and it uses RAZOR to support the view engine.
For any non-trivial new projects, ASP.Net MVC is the industry standard.

How is the best method to generate a url with ASP.NET?

I will apprecaite your help in this topic.
I need to build a site with friendly urls using url rewriting in order to improve SEO positioning.
I've been searching torought web and finally pointing to this two main options :
asp .NET with isapi extension
asp .NET mvc
however, I got no experience on both items so I need you to help me to kwow further about this two technologies and to take the right decision for my needs.
Thanks
There are much bigger concerns than just URL setup when making this choice. You're talking about two completely different architectures for building your web pages.
You should make the decision on how you want to build your application, what skillsets you have available in your developers, etc. Both approaches will be able to handle the URLs that you need to generate for SEO considerations.
For public facing websites, I would personally choose ASP.Net MVC, because I find the development cycle shorter, more productive, more flexible and more maintainable than an ASP.Net webforms application.
Assuming you have a host/server that can run ASP.NET MVC (i.e. one that has the .NET Framework 3.5 Service Pack 1 installed on it), you can use the Routing Engine (System.Web.Routing) from ASP.NET MVC in a web forms environment, Phil Haack has a good updated walkthough at "Using Routing With WebForms".
There's also "How to: Use Routing with Web Forms" on MSDN.
Unlike an ISAPI filter, this enables you to use the routing engine to generate your internal links as well as responding to well formed links from outside.
I agree with womp. But there is one advantage i see in Asp.Net webforms that Asp.Net Mvc doesn't have: Rich Client Iteraction controls. Everything in Mvc in View layer is simple and functionality need to be build from scratch.
alexserver - at the same time of course, the fit between mvc and jquery is an overwhelming reason to abandon the rich clinet controls. that way, you can literally get your designer and/or a jquery UI expert to work on the view portions in isolation whilst you craft the model and controllers.

Can "classic" ASP.NET pages and Microsoft MVC coexist in the same web application?

I'm thinking about trying out MVC later today for a new app we're starting up, but I'm curious if it's an all or nothing thing or if I can still party like it's 2006 with viewstate and other crutches at the same time...
Yes you can have your webforms pages and MVC views mixed in a single web application project. This could be useful if you have an application that is already built and you want to migrate your app from webforms to mvc.
You need to make sure that none of your webforms pages go in the 'Views' directory in a standard ASP.NET MVC application though. Pages (or views) in the 'Views' directory can't be requested directly through the url.
If you are starting an application from scratch, there would be very little benefit to mixing the two.
Yes. MVC is just a different implementation of the IHttpHandler interface so both classic ASP.NET and ASP.NET MVC pages can coexist in the same app.
As you've probably noticed with the above answers, yes this is very possible to do.
I've actually had to do this on my current project. I was able to get approval to add MVC to our application, but only in the administration section (to limit the risk of affecting current members coming to our site).
The biggest problem I had was converting my Web Site to a Web Application, but once that was done, things were pretty straight forward adding MVC side-by-side our classic code-behind web pages.
The trick for me was to make my MVC pages look as similar as possible to my code-behind pages so the transition looked as seamless as possible.
I am currently working on a new project. While I would like to go down the MVC route all the way, some of the project requirements don't allow me.
One of those requirements is to have a grouping grid from the client-side. Personally have chosen the Telerik Rad-Grid. While they may be in the process of supporting MVC they are not there as yet.
So this means that I have to have a hybrid solution. for the time being until RadGrid fully supports MVC.
While we are in this transition period I think that there will be may more hybrid projects out there until the support of the Third Party Controls catches up.
Regards
Nathan
You'll need to make sure your MVC routes don't conflict with your Web Forms pages so that requests for a .aspx page don't get routed to a controller action as a parameter etc.
See this blog post by Phil Haack for details on how to avoid this.
Yes, it is very much possible for MVC pages to coexist with asp.net web forms. I implemented that in my existing asp.net application for adding new features. We need to make sure of referring the MVC DLLs, registering routing tables for URL routing and configuring the assemblies and namespaces in Web.config file.
If you're mixing MVC with other methodologies you're not really getting the benefit out of it. The point of MVC is to allow you to decrease coupling and increase cohesion, and if only half of your code is doing that, then the other half is inevitably going to restrain your development cycle.
So, I guess while it's possible, I don't think it's worth it. Go all the way or don't go at all.

Resources