I try using Server.Transfer instead of Response.Redirect because it saves a roundrtip to the server. However I noticed that Request.Path returns the path of the calling page and not the one of the displayed page after the Server.Transfer. I expected to see the URL of the old page displayed in the browser address bar but I was hoping that internally a page knew his own identity. I need to be able for a page to know the page that actually is being displayed but Server.Transfer tricks me. Is there something to circumvent the Response object for the page to know exactly what page is loaded? --- Edd
laphijia
Posts
-
Request.Path after Server.Transfer -
Remove those nasty <FONT> tagsI'm building my pages using CSS so I don't need/want visual studio to put any tag in my aspx file. Worst the tag is deprecated in HTML 4 and should generate an error in XHTML. I can remove all occurrences manually but it takes time and makes maintenance a nightmare. Is there a way so that Visual Studio stops trying to be smart? Edd
-
Menu ControlsI'm building a website and I'd like to use one of those dynamic menu that can be programmed as a server control from ASP.Net and render as JavaScript in the browser. I found that many of them offer unlimited trial time for developers so I began playing around with ASPnetMenu by CYBERAKT. I have to say that it's pretty advanced stuff since the menu has great graphics and it's very functional and customizable. Then I read the recent article by jconwell here on CodeProject about performance strategies for web applications. So I decided to do some stress testing. That menu is TERRIBLE. The Aspx pages I wrote are pretty complicated and I was really worried about their performance since they are really database intensive. To my surprise I found out that my code it's actually pretty good but using that ASPnetMenu has disastrous effects on performance. Here are my results from testing 3 pages using Visual Studio ACT on a Pentium 4HT 2.6 Ghz 256MB ram accessed over the 100base-t network using my Pentium 3 1.1 Ghz Laptop: 25 simulteneous browser connections for 1 minute. With ASPnetMenu: Iterations: 2,438 Average request per second: 188.78 Average time to first byte (msecs): 28.89 Average time to last byte: 44.71 Errors Counts HTTP: 7,879 Errors Counts Socket: 6,634 -Response Codes- 500: 1.39% 403: 68.16% 302: 21.76% 200: 8.68% Without the menu: Iterations: 2,646 Average request per second: 261.75 Average time to first byte (msecs): 10.94 Average time to last byte: 11.30 Errors Counts HTTP: 1,453 Errors Counts Socket: 347 -Response Codes- 500: 6.67% 403: 2.59% 302: 64.15% 200: 26.60% While I'm aware that there still is a problem with too many errors even when not using the menu (any suggestion to possible cause would be appreciated) I know that I can modify my code while I cannot modify their menu and this casts a dark shadow on the feasibility of having a sleek user interface. Does anyone have any suggestion, any experience to share, or know about a good alternative and fast menu? Edd
-
User Control constructor has parametersI found out on MSDN that when drag dropping a control Visual Studio doesn't automatically create the declaration in the Code behind file. In fact if our control is called UserControl1 and is has a public property called StringProperty we cannot access it by default by calling UserControl1.StringProperty = "hello"; On MSDN they say to add protected UserControl UserControl1; Done this and accessing the control works. Anyway I still haven initialized my constructor. If I modify my declaration to protected UserControl UserControl1 = new UserControl(ab1, ab2, ab3....) I still receive the error no overloaded method for UserControl takes 0 parameters. I used a workaround of declaring a property and assigning it to the value I want on the Page_Load in my case works but there must be a proper way to do this. Edd
-
Opening an ASP.NET projectGo to Administrative Tools / IIS and right clik on Default Website then new/virtual directory and map it to the directory where you put your files (I see from your post that it's under My Documents/ Visual Studio Project/ that by default is not Web Shared) Also make sure to share on the network the directory with your files otherwise ASP user won't have permission to access it. Be sure to be working online. Check it in IE/File menu. Edd
-
Is Request.Path secure?I was wondering about using Request.Path to add security to my pages, like having different behaviors according to which page the user is. Anyway it came to my mind that IE had recently a bug that allowed a malicious user to display a page while displaying a different url in the address bar. Even though this was an IE bug I was wondering if something similar could easily be done so that an ASP.Net page is mislead to think that the path is different from what it actually is. Somebody has any info on this? What are you doing to check which page is the user on? Edd
-
Give name to table from stored procedureI've built a fairly complex stored procedure that has a couple of selects in it that are only functional while I'm only interested in reading the resultset from the last select. Now when I fill my dataset, apart from retrieving useless data from the database, I have to acess my data doing something like ds.Tables[2].Rows I have thought of two possible solutions even though I don't know how to implement any of them. 1. Have the stored procedure return only the last recordset. If this is possible I'm missing some T-SQL command. Anybody on this? 2. Give a name to the table that I'm interested in reading so that I could access it disregarding it's index like ds.Tables["MyRecordset"].Rows This is much more elegant than accessing with numeric index bacause if I change the stored procedure I don't have to change my code. Anyway how does one give a name to a table from a stored procedure? Thanks Edd
-
User Control constructor has parametersI build a user control and added a constructor to it. The constructor takes a parameter. Now when I put the user control in a web form (drag and drop) I don't know where to set the parameter. What happens is that I get this error: Compiler Error Message: CS1501: No overload for method 'ItemFields' takes '0' arguments Source Error: Line 31: private static bool __initialized = false; Line 32: Line 33: public ItemFields_ascx() { Line 34: if ((ASP.ItemFields_ascx.__initialized == false)) { Line 35: ASP.ItemFields_ascx.__initialized = true; Source File: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\AspProjectOne\2eab3c48\dc018b2c\onc_fead.0.cs Line: 33 Thing is I don't know WHERE to initialize the control with the parameter for the constructor. I was wondering if in the ASPX page is the right place: orHere??? Edd
-
OT: The price of running an ASP.NET applicationI know this is not strictly a programming question but instead it related to "How to run the applicaton we have developed?" I was thinking about developing an application using ASP.Net and then buying a server, a leased line, all the necessary software, in order to run it and make it accessible from the internet. I know that an option might be a third party hosting service but in certain cases it's not appropriate to outsurce because of privacy issues and other reasons. What I am looking for are the components, either hardware and software, that are required to properly, and legally, run an ASP.Net application that uses a database as a data store. And then the prices. My rough idea was that one needs to buy: - a server - Windows Server .Net 2003 - SQL Server 2000 - Visual Studio While for the hardware and for Visual Studio it seems pretty easy to understand the prices, I found that I cannot understand the licensing for the OS and the DB. Many licenses are sold on a User/Seat or Processor basis. But how does this relate to using the OS and the DB to deploy an ASP.Net application over the internet? Does one have to buy a seat for every web surfer that access our web-app? (sound effect: laughing in background) Or what? Processor licenses seem adequate but they are sort of expensive. Anybody on this? Thanks and happy new year. Edd
-
No expert of ASP.Net on codeproject????Is the folder shared for users in the network? If it's not Visual Studio cannot connect to debug.
-
Salted Hash add vulnerabilitiesI was going through the process of deciding how to store my passwords in a SQL Server database. I was using the basic hashing approach when I came through the idea of trying with salted hashes. When using normal hashed I didn't need to retrieve the password from the database. What I would do was to use a stored procedure like this. CREATE PROCEDURE [dbo].[proc_authenticate] ( @UserID nvarchar(16), @Password nvarchar(64), @SessionVariable nvarchar(64) ) AS DECLARE @AuthUserId nvarchar (16) SET @AuthUserId = (SELECT UserId FROM Users WHERE (UserID = @UserID AND Password = @Password)) -- IF ABOVE SELECT RETURN ONLY ONE ROW THEN STORE SESSION VARIABLE IN LOCALS TABLE ELSE RETURN IF @AuthUserId = null RETURN UPDATE Locals SET SessionVariable = @SessionVariable, LastLoginDate = GETDATE() WHERE (UserID = @UserID) GO Basically in my application I would ask the user for a username and password. Then I would generate a random session variable. I send everything to the stored procedure on SQL Server. It's the stored procedure that does all the authentication and there is no way to read a password if not by compromising SQL Server and gaining SA privileges. On the other hand the approach with salted hashes is different. 1- Retrieve the stored password and the salt for an user using a stored procedure. 2- Extract salt 3- Calculate salted hash of user provided password 4- Compare stored password with user provided 5- If they are the same call a stored procedure that given UserID writes a ticket in the database. Step one means basically giving away the User table to anybody that can steal our connection string. This in my opinion is a security problem because basically just by cracking the user of our connection string we can retrieve any password from any user. Of course it's hashed and salted and the malicious user has to guess a username but he can use a brute force attack to decode a password. With the previous approach instead to use brute force attack he would have had to call the sored procedure once for every attempt. This would have slowed him down and would leave a trace in our logs of a suspect activity. But since we cannot autheniticate from inside a stored procedure using Salted Hashes we have to retrieve the password. In this case an attacker can perform the brute force attack on his own computer without any delay from accessing our server through the internet and without leavin any trace. Step five is even worst because one can just byp
-
Page updates only on second clickI am trying to implement localization in my webpage as described in the Microsoft walkthrough. The Microsoft example reads the CurrentCulture from the client browser preferences but I would like to implement the classic style when on a webpage there are different links to start rendering the pages in a different language. I inserted two buttons one called English, the other Italian. When the user clicks one of the two buttons it sets Session["l"] to either "en" or "it". On Page_Load I have the following code: if (Session["l"] == "en") { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); } else if (Session["l"] == "it") { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("it"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("it"); } This works fine with only one caveat: the language changes only when I click the button twice. More importantly if the page is rendered in English and I press the Italian button the pages reloads in English. If now I press the *English* button, NOW the pages renders in Italian. It seems that there is a delay. That is when I press the button to change Session["l"] to the appropriate settings this is not read immediately by the Page_Load when rendering the page after the PostBack, but only the next round. Why is it so? I can't figure it out and more importantly how to solve this. Thanks.
-
DropDownList loses selectionI populated a DropDownList from SQL Server public void PopulateDays() { DataBaseAccessor dba = new DataBaseAccessor(); ddtFromDay.Items.Clear(); foreach(DataRow dr in dba.LoadHoursAndMinutes().Tables["HoursAndMinutes"].Rows) { ListItem li = new ListItem(dr["Hours"].ToString() + ":" + dr["Minutes"].ToString(), dr["ID"].ToString()); cbFromTime.Items.Add(li); cbToTime.Items.Add(li); } } Then I have a button, Add, that when clicked copies the current selection on the Drop Down List to a List box. private void btnAdd_Click(object sender, System.EventArgs e) { ListItem li; //Selected item from DropDownList li = ddlFromDay.SelectedItem; //Add item to ListBox lbDates.Items.Add(li); } The problem I face is that once the Add button is pressed the page posts back and I lose the selection on the Drop Down List therefore no matter what was previously the user selection it always adds the first item in the Drop Down List to the List Box. It seems that is not EnableViewState but indeed it is. I checked that already. I'm using cookieless StateSession and I tried to add the current selection to it but without any success. The real issue is that for me to perform ANY kind of action, even storing the current DropDownList.SelectedIndex to my StateSession, the page goes in post back and I lose the selection before I can memorize it. There must be something in how Drop Down Lists work that I'm not getting quite right. :zzz: Night coder: also today it's 6AM.
-
Special requirements for Mobile Forms HostingI'm trying to develop a small client using Mobile Web Forms. Basically it's the porting of a more complex Web ASP.NET application. It seems to work properly using the phone.com WAP simulator even though I couldn't test it using other than my iPAQ because both my mobile phones (Samsung V200 and Ericsson T39m) seems not to be supported by Mobile Web Forms. Anyway I'm assuming everything it's working. I also tried using the iPAQ connecting via GPRS to my PC IP address, so that I'm not running local. Now I'm looking to host my application to do more serious testing. I've been searcing for some good ASP.NET host in my country (Thailand) that also offer SQL Server 2000 database. I found some that offer really good rates and satisfy all my requirements but I cannot find out if they support Mobile Web Forms. Is there any special requirement from the host or if they can host "normal" ASP.NET pages that use Web Forms that means that they can automatically support Mobile Web Forms pages? Thanks for any answer. ;)
-
Find the greatest and the smallestHello, I have a database where I store points by memorizing their coordinated in two columns namely x and y. I have written a method that allows the user to insert two arbitrary coordinates (x,y) and the method will return all the points in a 1,5,10,..n km radius. With these query result I want to find the point with the smallest x coordinate, the point with the greatest x coordinate, that with the smallest y coordinate, and that with the greatest y coordinate. I need to do this in order to be able to fit all the area that has been returned into a 200x200 pixels area. The first idea that I got is to sort the dataset by column x and extract the first and last record, then sort again by y column and do the same. Is there any better way to achieve this? I need fast performance because the program will be computing thousands of query from different users at the same time. Thanks in advance, Edo
-
GIS in C#I need to make an application that reads from popular GIS file formats like ESRI Shape File or MapInfo TAB. I found the open source GeoTools.net but they apparently don't work and the website on sourceforge is not really being updated. Is there any open source or free library out there for use with .NET? "Nelle cose del mondo non e' il sapere ma il volere che puo'."
-
Static TextBoxt that keeps disappearingThanks for the hint, I was pretty sure that there was something wron, even if it actually worked! :( But it seems that now I have a problem that I don't know how to solve. I have a class Display that I use to perform all the stuff related to the display, that actually is my control box. For example I need this class because it keeps track whether when the user pushed a button he's beginning a new number or adding a digit to the number currently onscreen. Things like that. The problem is that I don't know how to access the control that is on the form. You know they are in two different classes. Of course I cannot inside class Display write tbDisplay.Text = "whatever"; nor Form1.tbDisplay; etc. How this is supposed to work? Thanky you a lot! Edward
-
Static TextBoxt that keeps disappearingHi folks, I'm just beginning with C#. I am doing an RPN calculator and it seems to work pretty well. However I have a problem. I have a class that manages the stack, and a class that manages the displaying of numbers on the display, that actually is a TextBox, tbDisplay. Since the TextBox in on the main form, the one that gets created automatically when you use the form designer, I have to access it from the display class. How do I do it? What I did is declaring the TextBox public static. After from the display class I access it using Form1.tbDisplay. It works! The problem is that everytime I add a control, or do "something", something being I don't know exactly what, the TextBox disappears. It seems that VisualStudio removes the lines of code. What VS does is not removing the declarations of the control, public static etc..., but it removes the lines in the initialization. It removes the line from the this.Controls.AddRange. It also removes these lines: Calc.tbDisplay = new System.Windows.Forms.TextBox(); // tbDisplay // Calc.tbDisplay.Location = new System.Drawing.Point(136, 56); Calc.tbDisplay.Name = "tbDisplay"; Calc.tbDisplay.Size = new System.Drawing.Size(208, 20); Calc.tbDisplay.TabIndex = 18; Calc.tbDisplay.Text = "0"; Calc.tbDisplay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; This happens all the times. It's the tenth time I add the lines back by hand, it's a mess. What's the problem here? I suspect that my approach of declaring it static.. etc it's not the right solution? How should it work??? How do I, from inside Z class, control an istance of a X class that is declared into Y class? Thanks for any help. I hope to finish my calc so maybe I can post my first arcticle on CodeProject. It uses a nice stack class. And it behaves exactly like the calculator I am emulating, the HP 12C.:-D Edward
-
Complex relational databaseHello, I have made a database - SQL Server 2000 - to handle some stuff e.g. contacts, orders, etc. I tried to normalize the database the best that I could and this lead to a lot of tables. For example since the contacts are worldwide, there are 3 tables that each one, hierarchically store country, province, county. Finally in the table where each contact is contained i just store the ID of the county, and the province and stare would be retrived through the realationships. Ok, this is just an example, the thing is much more hierarchical and normalized. I would like to know how can I practically retrive, use, and update data from this database using ADO.NET? I mean, I am a bit confused. Is there a simple way or is it going to be a mess all do be done from zero? Thanks for any help. Edoardo
-
Wizard DialogHow I get the feel of a Wizard dialog in C#/Windows Forms? I would like to make dialogs that acts like wizards. Now I am using a buggy procedure of overlapped panels, that I hide and unhide. What is the proper way to do that? THX "Nelle cose del mondo non e' il sapere ma il volere che puo'."