it still does not work, the user writes appendix then press OK in Login, nothing happens
here is the login (vb.net)
Partial Class login
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Session("passcode") = TextBox1.Text
Response.Redirect("Default.aspx")
End Sub
End Class
and here is the default page C#
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["passcode"] == "appendix")
{
Response.Write("OK !");
}
else
{
Response.Redirect("login.aspx");
}
}
}
Example scenario: User login has a list of associated 'accounts' it has access to... this list of accounts is stored in a database table, say tblAccountAccessControl, something like:
This info is used throughout the web application and determines the 'domain' of information the particular login has access to. For example there are many other tables that have the 'accountID' field and whenever a page pulls data from the table it only pulls data that the currently logged in user should be allowed to see, based on that tblAccountAccessControl data.
The security question: Do I need to query the database every time I need to get this list of allowed accountID's? I was about to use a plain old query string to pass a particular accountID to another page but quickly caught myself as I realized that would be a major security flaw (the receiving page was going to use that accountID to grab info from the database, and there would be nothing preventing a user from simply typing in a url manually to get data from an accountID they are not supposed to be allowed to view). So I then thought I'll just store the list of accountID's in a session state variable so they will be carried with the user throughout the session.
But then I remembered there are tools out there that allow you to easily intercept and modify asp.net viewstate information and I'm not sure if that would included session state variables, but I'm guessing they would. Is there a way to create a secure query string? If I used session state would that session state information be exposed and modifyable by utilities out there? Am I just stuck having to query the database every time I need this info to assure security? What about encrypting it and then storing in session state variable (just thought of that one)?
I have this code that loop through table controls how do stick the seleted information into a session variable. Then i have to pass it into another page table control.example code
I would like to know if the way i'm dealing with session variables is the right way, and also how to fix this error i'm getting: FormatException: Input string was not in a correct format.
Currently in an .aspx file, I am storing a value (filename that was created in that session) in an hidden text box. When the user clicks on the "Print" labeled Hyperlink control, it opens the file that was stored in the hidden text box control. But when the user goes to different screen (in the same session), I loose the filename value that is stored in the hidden text box control. So I would like to store the filename variable in a session variable. So that if the user leaves this .aspx file and comes back to this .aspx file I can load the value into the hidden text box from the session variable.
I have a web application which uses a session variable to store the logged in userid. If no user is logged in, of course this variable will be empty and the contents displayed on my website are meant for guests. If there is a user logged in, the user specific controls/access/links will then be a displayed.
I am now having issues with my hosting where on shared application pool, the worker recycle is triggered every 90 minutes, this will clear sessions causing all my users to be logged out. I opted for a dedicated application pool, which got worse because I am only allocated 50MB memory limit and if this is reached, the worker recycle is triggered and I lose my sessions again. I have tried as much as possible optimization techniques, e.g. dispose where possible, close connections, disable viewstate for static controls etc but my memory per instance keeps building up from page to page without any signs of improvement. I don't use loops nor store huge objects like bitmaps etc but my sessions are now gone even faster than 90 minutes in shared application pool before.
I have considered using SQL Session State but there isn't a simple guide on using this with MySQL. I am getting desperate and considering using a public variable, a string as a replacement to store logged in user id instead of in a session variable. I am pretty sure this will solve my issue with sessions being recycled but are there any negative consequences of doing this? One problem I can think of is if the user closes the browser, the system will never know that the user is now logged out and this public variable should be nothing. In this scenario, will the GC eventually clear this abandoned public variable.
What would be the proper syntax in ASP.NEt 3.5 C# to assign a TextBox value to a temporary or session variable to be manipulated (added, subtracted, multiplied, divided) at different points in the application? I want to add a decimal number to this variable in almost every instance as well.
I have the dataset. in this i am having total 20 tables with huge amount of data..I want use this data over all the page..so where i can keep this data..
before i used viewstate but the viewstate data is render to page every postback ..so this time the page size is increasing(interanlly viewstate is rendered to page)..so performence wise it was very slow..
Now i change my logic insted of viewstate to i used Globel Dataset on Page Level.. now the performence wise better than viewstate..
i used Like shared dsControls as Dataset at top of the page..so every time i use this dataset..
my quesation is session is better or Globel variable is better way use in my situavation..
I added the following code to global.asax to load up several session variable when a session starts. I'm assuming that when a page goes to use the variable that I should be
1) checking at the page level that the value is valid not 0 when its not expected to be 0, not a zero-length string when its expected to have a length
2) have code at the page level that sets the values if the values have not been set as when the Session timeout, ideally putting the code in a class derived from Page and then deriving all of my pages from the new class so that the code does not have to be repeated in every page
I have some code in my page load event where I just want to fire once when the user opens the Browser. The only issue is if you open a new tab with the same website the session variable does not reset. Is there a way to reset the session variable when you open a new tab or do you have to take the whole web browser down for it to clear the session variable.
I have been spending a better part of a week trying to track down why I am not able to clear all session variables in a web app (vs 2010, vb.net). What I have tracked it down to is that when I remove or abandon sessions that my html pages or codebehind access, it works, but for some reason in any of my class files where I use "Public Shared strConnection as String = HttpContext.Current.Session("strConnection").ToString" to access a session variable, it finds the old one and not the current one. I have to wait for it to time out, go in again, and it will find the new one.
I do not use Linq, and there is only one place in the whole web app that I place the connection string in a variable whcih is when a person logs in. It points them to the correct database. The sqlconnection is set for all of my listviews in Page_Init to make sure that they aren't using any session variable that they create on their own. Interestingly enough that if I use debug to go in each time, exit debug, enter debug again trying to access a different database, it works correct each time. I assume that debug is correctly killing the session variable for the classes for me.
I have some cascading dropdownlists using the ajax toolkit I have a set up datatables in an xsd file. Then use these in a webservice to populate all the fields ... this all works great but now i need to pass an additional paramter to the first dropdownlist ( a date) but don't know how to do this? The method is below...
[Code]....
The other code is:
[Code]....
The first change would be to the tableadapter to add a param to the code i.e
AuditWebDS.TeamsDataTable teams = teamsAdapter.GetTeams(calldate);
but how do i get the calldate param to the webservice method... i tried a session variable but it comes up with session is null ? Is there another better way?
my column data is from 'nvarchar' type and the data for my text box is from string type. when i want to compare these value , the expression always is false . even when the values are equal. i use Convert.toInt32 for my column have dataType int but in this part i want compare two string type.
I have a textbox for a child's name. The user may enter just the first name, first name + middle name, or first name + middle name + last name for their child. How do I separate this string of texts appart so that I can compare it to the parent's last name textbox before inserting into the database? For example, if one part of the three parts in a child's name matches the parent's last name textbox then delete this part out of the child's full name before inserting into the database.
I have a textbox control with a calendarExtender. I want to make the user select a date subsequent to Today. I have a public function, called display_error, written that displays some text in case of validation not successfull. So in this case, the validation of the date inserted by user would look like [Code]....
So, my textBox.text is a string, which I need to convert to Date to compare it to Today. Here's what I've written [Code]....
I've tried different methods, like Parse, but I keep getting the same error, String was not recognized as valid DateTime.
I'm just stumped on what to do with this code, I'm just trying to implement a 'no duplicates' catch on my insert customer form, but it just slips through my if statement to the else everytime. This is the source. Also I tried a .Equals with the same results :(
Protected Sub srcAllClients_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles srcAllClients.Inserting 'Establish Variables Dim emailAddress As String Dim srcUsers As SqlDataSource = New SqlDataSource() srcUsers.ConnectionString = ConfigurationManager.ConnectionStrings("ISSD21ConnectionString").ConnectionString Dim view As DataView view = DirectCast(srcUsers.Select(DataSourceSelectArguments.Empty), DataView) srcUsers.SelectCommand = "SELECT EmailAddress FROM ISSDClients" srcUsers.DataSourceMode = SqlDataSourceMode.DataReader Dim reader As IDataReader reader = DirectCast(srcUsers.Select(DataSourceSelectArguments.Empty), IDataReader) emailAddress = FormView1.FindControl("txtEmail").ToString While reader.Read() If reader("EmailAddress") = (emailAddress) Then lblError.Text = "Your Email is NOT Unique!" 'this is where we cancel the update and return an error Else lblError.Text = "Your Email is Unique!" 'nothing needs to happen, maybe just tell them that it went through End If End While reader.Close() End Sub
if i have string with "1,2,3,5" how can i have another record at least to have "1,2,3,5" in new data if it is "1,2,3,4,5" then it is true. if the new data is "1,2,3,4,6" , then return false becuase it is missing 5.
I have a string value from a user input box. I have to figure out if last char is a enter key (line feed).
Thats the code. Here I am checking if last char has a whitespace. Now I also have to check if last char is enter key (carriage return or line feed). How can i do this? var txt = $get("<%= txtUserText.ClientID %>"); if (txt.value.substring(txt.value.length -1) !== ' ' || <checkifLastCharIsEnterKey>) //my code to take action
**I don't think i need a keypress or keyup event because this above piece of code is not invoked at the time of user input.
I am new to asp.net Can you please guide me what is session and session variables ? Please I don't need a comparision of asp session and asp.net session because I don't know anything about asp. I have saw many articles on types of session as well. But still I cant understand exectly what is session and what are session variables in asp.net ?