Using Webform page in Classic ASP website - c#

I am updating some functionality in a classic asp website and basically to make populating a drop down happen after a value is selected in another drop down I am trying to change that page for a webform page with code behind. However, for some reason I just get the following message when attempting to go to that page:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Is it possible to have the webform in this site? Is the issue something to do with IIS or caching? I don't actually have access to the server to refresh the IIS or anything so some clues about what could be happening would be useful before I go any further.
Thanks.

I just talked to someone about this and it is possible to run a webforms page in a classic asp site but the site I am working on uses a lot of session variables which are not transferred between the asp and aspx pages so it is not going to be a viable option anyway. I am going to use ajax to populate the select list.
Thanks.

Related

Can we set server-side session by making http call?

I am migrating old ASP.NET WEB Form project to Angular app with ASP.NET web API.
The requirement is to merge the newly designed angular module (say login section) with old asp.net application. The new application should be functional and work together with the old ASP.NET web form project.
Now the problem I am facing is, when I log in and try to navigate to other .aspx pages, they need some session values (which old login page used to set) to work without breaking the application.
I tried to achieve this by making HTTP call to a dummy .aspx page. I passed all the session values as query parameters and set in on the server side. It's working fine.
Is it a right approach for achieving this or is there any better way? Will there be any complication later as the application grows?

Easy way to redirect page when site not available?

We have a regular asp.net website. I started debugging several errors, so the website cannot be used (but is not down). Since the default page is not Default.aspx and users are used to going directly to Main.aspx, if anyone goes to http://network:1332/Main.aspx, the person should be redirected to Issues.htm.
Is there an easy to do this without having to alter Main.aspx or write any code? Maybe change web.config or some IIS 6 configuration?
I just don't want anyone to use the website even though the site is available for use.
Thanks.
If you have an ASP.NET web application site, and you place a text file
named "app_offline.htm" in the root of the site, all requests to that
website will redirect to that app_offline.htm file. Basically, if you
need to take an entire ASP.NET site offline, you can place some nice
message in that file.
https://forums.iis.net/t/1152788.aspx?Put+website+in+maintenance+mode
Be warned you too will be directed to the maintenance page, so if you're debugging in production this could make things more difficult.
You can use Url Rewrite Module to IIS. Then you will be able to define your rewrite rules in web.config or using IIS Manager. Check this : https://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

Use setting to choose Webforms url or MVC route

I am working on a large production SAAS Webforms application that is going to be slowly migrated to MVC 5. We want to be able to let some customers 'opt-in' to the new MVC pages as they are deployed based on a configurable setting.
The MVC application will be in the same project as the webforms application. The conversion to MVC will go feature by feature to basically create a complete MVC application standing side by side with the webforms application. Once all features are implemented and customers have converted we will remove the webforms project and keep only the MVC project.
If a customer 'opts-in' then we want them to view any MVC views that exist instead of the original aspx page. If an aspx page hasn't yet been converted to MVC OR they customer has not opted-in, then we want them to view the aspx page.
My main concern is preventing the user from manually entering in a url and going to an aspx page when they should be viewing a MVC page or vice versa. Since this application is a multi-tenant system, it cannot be just set in the route configuration because those are only loaded once when the whole application starts. Whatever solution needs to dynamically check the opt-in setting for each user.
Where would be the best place to honor the 'opt-in' setting to force the user to the new MVC route instead of the legacy aspx page if both exist and what is the best way to implement this logic?
A couple of co-workers mentioned that it might could be done using a HTTPModule that checks a collection of aspx page to MVC route mappings.
Basically:
If optInToMvcSetting == true && url.contains(".aspx") Then redirect to corresponding route found in aspxToRouteMap.
If optInToMvcSettings == false && !url.contains(".aspx") Then redirect to corresponding aspx page found in aspxToRouteMap.
Does anyone have any thoughts or advice?
Why not use both?
Leave the WebForms aspx pages as is and then add the MVC routes as features are converted.
Then you can simply maintain two separate navigation renderings, one for WebForms and one for MVC. By default show WebForms but if a user opts in, show MVC. A browser cookie would be sufficient to provide this functionality.
The MVC navigation will initially include aspx links but as the conversion progresses these will be swapped out for their MVC counterparts.
The MVC routing is smart enough to distinguish between an MVC route or an aspx page.
This question contains information for your problem.

windows form application to web page application

I have this requirement for my project. Already there is an existing windows form application,
Which sends email when a button is clicked. There's a lot of code behind the application.
It validates the field serial number which is a text box by connecting to database.
The validation error pops up as another windows form.
It generates a report form after sending an email. There's a configuration button which is accessible only to particular users which opens configuration form which has details of email settings.
Now All this is developed using windows forms. My new requirement is i need to develop
the same in a ASP.NET web page having similar functionality.
I tried using click once deployment, but that's not they needed. they want it as a webpage.
Is there any tool or way i can show the application in ASP.NET web page?
Do i need to start the coding from scratch?
Thanks in advance
As to what Rex said, you are going to have to start from scratch. The coding behind it is different. Validation and functions work differently in asp.net than they do in .net.
You will have to start from scratch for reasons already mentioned. If this is your first ASP.net application here are a few tips for what you want to do:
1- For validation and transfer to the email report to work in a similar way you can use Response.Redirect or Server.Transfer or JavaScript. All of those methods have pros and cons, see Server.Transfer Vs. Response.Redirect for an example of the first two. For javascript you'll need to write a javascript function in the .aspx file or inject javascript in the page with response.write.
2- If you validate with JavaScript you also need to validate server side to make sure someone doesn't try to pass bad values to you. JavaScript can be disabled and users can call your report page and configuration page directly, while with windows forms you control that flow you don't on webpages.
3- You'll probably have to use CSS to style elements in your email configuration form and in your initial form. Positioning, docking, anchoring and so on is completely different in webpage and done with CSS. Have fun learning the CSS boxing model, what absolute positioning is, and what clear and float do ;)
4- The most important thing is that the Web is stateless. You can't use private members to keep information between page reload on the web. When you pass a value between 2 pages the first one doesn't exist anymore so you can't just do Class.somemembervariable as usual. Check out what viewstate, sessionstate and querystring are. When your page reload, without these, everything is loss. Clicking a server-side button cause the page to reload, which you need to handle (it's called postback). This also implies that when you serve the report page you will have to pass some Id for the email and check the user, so when you call the 2nd page you need to pass to it some id so it can work. I spent more time on this one because it's the most important difference between asp.net and windows form.
5- For restricting access to your email settings page you will probably need to use windows authentification if this is an Intranet site or Forms authentification if this is an Internet site. Check Starting ASP.NET Forms Authentication for some basic overview.
6- ASP.Net has a codebehind file where you write the actual code, and an .aspx page where you put the html tags, javascript, styles, and data binding with <%= %> tags.
7- You will probably have to work with IIS as well to make your website work unless you work at a very formal place where specific peoples take care of that. At the very basic you'll have to create an application pool, make it compatible with 32/64 bits and set up authentification in IIS.

How to get the source code of a aspx page

I want to get the main source of an aspx page.
How can i be able to know as to which and all links been created to get that site. When I right-click on the page, I get some Html page...but cant use it for compilation. Is ther some other way to approach this.?
Help me out as i'm new to asp.net 4.0.
and yea, 1 more thing, I just need to get the UI design tags which produced the page.
Thanks in advance...
You can't do it... Unless you are local on the same machine OR Have ftp access onto the server. OR when IIS is not configured to server asp.net application.
Unless you have access to the server where the files are hosted you cannot see the source code.
ASP.NET is server side, so when you request the page the web server (IIS) will use the ASP.NET engine to do the processing on the server and then construct the HTML, which is the output you see in the browser.

Categories

Resources