|
tanx for your kind reply, now i want to clear whether i'm having a correct idea about the session.
when a user logged on to the system i'm trying to keep it in the session.what i want to know is whether the server keeps a collection of session objects to keep the information related to the logged on users.
and in the previous code session gets a key and a value, so when we set the same key it should give an exception like hash table, isn't it
|
|
|
|
|
prasadbuddhika wrote: what i want to know is whether the server keeps a collection of session objects to keep the information related to the logged on users.
For every client Session data store separately, means session data is stored as per client basis.
prasadbuddhika wrote: and in the previous code session gets a key and a value, so when we set the same key it should give an exception like hash table, isn't it
No. The code which you have provided is not doing this at all.
Mine was a alternative approach.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
|
Hello there people I'm working on an ASP.NET website using C# code on VS 2005. My problem is that when using the Login controls like the Registration Form, Login Control, Login Status, Change Password, etc, I don't want the project to create a .mdf file. So, I made a connection string in the web.config file to use my SQL Server 2005 database. The problem is how could I make this kind of registration type of site? I've tried searching tutorials but with no success. I want the site to be able to handle registrations and logins using my SQL Server 2005 database
Website type is: Shopping Cart.
Problems I'm encountering:
1. I need to know how to use login controls using an SQL Database which is not created automatically.
2. I need to know hot to tackle permissions, like I have the main site to be available to non-registered users and registered users but I don't want anyone to access the Administration site.
File Structure:
Folder -> Administration
Admin.aspx
UserList.aspx
Folder -> App_Code (to store the code of the cart/other functions
Code.aspx
Folder -> App_Data (not used because I want to use an external Database)
Folder -> App_Themes (to store stylesheets)
Folder -> Images to store all the images
Folder -> Catalog (contains the products cathegories)
Folder -> Login
Login.aspx
Register.aspx
ChangePW.aspx
RecoverPW.aspx
RecoverPWConfirmation.aspx
Default.aspx
MasterPage.master
Admin.master
I'm Using two master pages, one for the whole site, and one for the administration.
I want to use the main login with a hard coded admin privileged user in the database to access the administration and no-one else.
My DB has a table named user Permission where it has the PermissionID(PK)(1, 2), PermissionType(User/Admin) and have a table named Clients with the Client ID(PK), Name, Surname, PermissionID(FK)
So far this is the code I used for the Web.Config File
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.net>
<mailsettings>
<smtp deliverymethod="PickupDirectoryFromIis" from="Admin@ImagineComputers.com">
</smtp>
</mailsettings>
</system.net>
<appsettings />
<connectionstrings />
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" />
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<rolemanager enabled="true" />
<!--
Role manager is used so that users can have certain
privelages and Administrators have all privelages
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
<!--
Mail settings used for online server
-->
<!--<mailSettings>
<smtp>
<network host="my.mail.server" />
</smtp>
</mailSettings>-->
</configuration>
And this is the code of the master page:
<![CDATA[<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>]]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="App_Themes/StyleSheet.css" rel="stylesheet" type="text/css" />
<title>Test Computers</title>
</head>
<body>
<form id="form1" runat="server">
<center>
<div id="topContent">
<table id="topTable" cellspacing="0" cellpadding="0">
<tr>
<td>
<br />
<br />
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
</center>
<center>
<table id="mainContent" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="leftContent">
</td>
<td id="middleContent">
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server" xmlns:asp="#unknown">
</asp:contentplaceholder>
</td>
<td id="rightContent">
<asp:loginname id="LoginName1" runat="server" style="position: static" xmlns:asp="#unknown" />
<asp:loginview id="LoginView1" runat="server" xmlns:asp="#unknown">
<rolegroups>
<asp:rolegroup roles="Admin">
<contenttemplate>
<a href="Administrator/Administration.aspx">Admin Page</a>
</contenttemplate>
</asp:rolegroup>
</rolegroups>
</asp:loginview>
<asp:loginstatus id="LoginStatus1" runat="server" style="position: static" xmlns:asp="#unknown" />
<br />
<br />
<img src="Images/Site/cart.jpg" alt="Cart" style="float: left;" id="imgCart" />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Items:
<br />
Price:</td>
</tr>
</table>
</center>
<center>
<div id="bottomContent">
</div>
</center>
</form>
</body>
</html>
I hope this long question is not too bad for someone to help me. I thank you beforehand!
Regards,
Francesco (Junior Programmer :] anxious to learn)
|
|
|
|
|
Hi there!
I've just been doing the same thing as you and ended up with creating my own registration system.
Mostly because thats what I'm used to from the days of standard ASP and include files.
Basically I created an object called SessionContainer that I store in a session variable which contains a bool value that tells me if the current user is logged in or not (IsSignedIn).
This container also contains the signed in user (if signed in).
I then created a object that inherits from System.Web.UI.Page and all the pages in my sites inherits this object.
And the object has a public property so I can access the SessionContainer.
So in your administration pages you can just check IsSignedIn, if false then redirect to something else..
And yeah I got two master pages, one named defaultMaster (for non-secure pages) and another nested masterpage named secureMaster.
secureMaster checks the level of security for the current page (None, ReadOnly or Restricted). So I can set the level of security on each page.. Some pages I let the user read but not write and some pages are off-limit to non-signed in users.
You dont need two different masterpages, but I needed some design changes in the secure pages so I ended up with this solution.
Sorry for the poorly description, but maybe you get the idea.
If not I could easily create a little project for you to look at and play with.. Just let me know and I'll throw something together.
I'm not saying that my way is the only way, but it works
|
|
|
|
|
Yes I get the idea, so I make my custom controls using textboxes/labels/buttons etc to connect to my database. So that's problem solved.
Second prob which is of administration. so I add a field to the client table as IsLoggedIn (as bool - Yes/No) and make a session. Now do I have to create the session in the master page? And how should i create it?
Also another idea is:
For the administration page, while the user logs in, I check for the username and password the client has together with his permission. If the username and password match, the user is logged in as a normal registered user (if permission is User). If the username and password entered are in the database and his permission is Admin, he is redirected to the Admin page. Is that a secure solution or?
If you could send me some sample small login with the session please do so. I'm not requesting the whole code, just a sample so as to help me make this type of feature in my website. Thanks!
I thank you for the help and for administrators, sorry that I've made my question too long.
Thanks!
|
|
|
|
|
Did you every look at your question after posting, that how it is look like ?
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
You can easily use ASP Membership with a SQL database. You were on the right track by updating the web.config with a connection string to the sql server. The only step you need to take after that is running aspnet_regsql.exe . This file is located in C:\Windows\Microsoft.net\Framework\v2.0.... When you run the aspent_regsql.exe it will bring up a wizard that allows asks you for your database server and login credentials. This will create all the necessary tables you need for ASP.Net Memberships in your database. After that you should be good to go. Also this msdn link is very helfuull
http://msdn.microsoft.com/en-us/library/879kf95c(VS.80).aspx[^]
Hope that helps.
|
|
|
|
|
Originaly posted at channel9, but without any success so I'll try here.
I started out to create a simple (but cool) image uploader.
I created a new web project just to test and got it working.
I then copied the code over to my real web app, and guess what; it didnt work!
I upload the exact same picture from both applications, but only the one from my test project can be displayed.
If I try to display a picture uploaded from the real app in my test project I also get the "Parameter is not valid" when doing Image.FromStream().
So I guess there's something happening when it writes the data to the db, but I just cant find out what. Its the exact same code in both web apps.
Heres some code;
From my test app:
private void SaveImageToDb(Stream imgStream, string contentType, int byteLength) {
string sql = "INSERT INTO sysTmpImg_TempImage (sysTmp_recno, sysTmp_contentType, sysTmp_image) VALUES(@recno, contentType, @image)";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["myPetDb"].ConnectionString);
SqlCommand com = new SqlCommand(sql, conn);
byte[] biImage = new byte[byteLength];
imgStream.Read(biImage, 0, byteLength);
com.Parameters.Add(new SqlParameter("@recno", Session.SessionID));
com.Parameters.Add(new SqlParameter("@contentType", contentType));
com.Parameters.Add(new SqlParameter("@image", biImage));
if (conn.State != ConnectionState.Open) {
conn.Open();
}
com.ExecuteNonQuery();
conn.Close();
com.Dispose();
imgStream.Dispose();
LoadImage(Session.SessionID);
}
(load image just loads the uploaded image)
From my real app;
public void AddNewTempImage(int usRecno, string tmpRecno, Stream imageStream, string contentType, int byteLength) {
byte[] byteImage = new byte[byteLength];
imageStream.Read(byteImage, 0, byteLength);
string sql = "INSERT INTO sysTmpImg_TempImage (sysTmp_recno, sysTmp_US_recno, sysTmp_contentType, sysTmp_image) VALUES(@tmpRecno, @usRecno, @contentType, @image)";
SqlCommand com = DataHelper.GetCommand(sql);
com.Parameters.Add(new SqlParameter("@tmpRecno", tmpRecno));
com.Parameters.Add(new SqlParameter("@usRecno", usRecno));
com.Parameters.Add(new SqlParameter("@contentType", contentType));
com.Parameters.Add(new SqlParameter("@image", byteImage));
DataHelper.ExecuteNonQuery(com);
imageStream.Dispose();
}
I'll even throw in the code for the DataHelper object;
internal static class DataHelper
{
public static DataSet Execute(SqlCommand command) {
DataSet result = new DataSet();
SqlDataAdapter adap = new SqlDataAdapter(command);
adap.Fill(result);
return result;
}
public static void ExecuteNonQuery(SqlCommand command) {
CheckConnection(command.Connection);
command.ExecuteNonQuery();
command.Connection.Close();
}
public static object ExecuteScalar(SqlCommand command) {
object result = null;
CheckConnection(command.Connection);
result = command.ExecuteScalar();
command.Connection.Close();
return result;
}
public static SqlCommand GetCommand() {
return GetCommand(string.Empty);
}
public static SqlCommand GetCommand(string commandText) {
SqlCommand result = new SqlCommand(commandText, GetConnection());
return result;
}
private static void CheckConnection(SqlConnection connection) {
if (connection.State == ConnectionState.Closed) {
connection.Open();
}
}
private static SqlConnection GetConnection() {
ConnectionStringSettings connString = ConfigurationManager.ConnectionStrings["mainDb"];
return new SqlConnection(connString.ConnectionString);
}
}
Even though Im using the datahelper, the result should be the same...
I've created a generic handler to display the pictures and this is the line where it fails;
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
I could also include the code for the handlers, but since none of them can display anything I upload from my real app (but from my test app) I think the problem must be somewhere in the saving of the images.
I've checked the bytes and they match up in length from both the apps.
|
|
|
|
|
Are both databases the same ? Might the data be getting mangled as it's stored ? Have you tried storing a small image to both and then getting both byte streams and comparing them ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi and thanks for the fast reply.
Yes its the same database.
Now I tried with a smaller picture and still the same.
I've actually copied over EXACTLY the same code from my test app so the real app doesnt use the DataHelper object and I still get the same error
So yeah.. Im stuck..
|
|
|
|
|
What if you insert it with one page, and then try to retrieve it from the other ? This way you can tell if the issue is with the data going in, or coming out.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
thats what I'm doing now.
I upload the picture using my real app and try to display it in the test app, ending up with "Parameter not valid".
If I use the test app to upload it works.
So its clearly the storing of the images, I just cant figure out what it is. The code in both project looks exactly the same, the same db and the same connectionstring.. Go figure
I'll probably end up with saving to disk and just storing a pointer in the db, but I don't like to change the design just because I can't figure out the issue, if you know what I mean
|
|
|
|
|
Yeah. What if you compare the bytes that are stored then, to try to work out how they differ ( are they the same size ? Are they modified in some consistent way ? )
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hey
I have a CompareValidator checking that and end date is after a start date. I enter two dates in dd/mm/yyyy format so for example:
start = 21/03/2009
end = 22/03/2009
The client side validation seems happy enough and doesn't whinge. However when I submit the form the server side sets the Page.IsValid to false and the specific validator's error message is shown. First thoughts were localisation settings so I added UICulture="en" Culture="en-GB" to the page tag. However the same response.
The client side seems happy but the server side doesnt.
Does any one have any ideas?
*Edit also tried uiCulture and culture as the msdn article had a typo.
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
modified on Thursday, March 19, 2009 6:41 PM
|
|
|
|
|
Hey
Half solved this, it seemed to be a "quirk" with a devx DateEdit control, I just replaced it with a text box with appropriate validation for now.
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
So I've searched for hours for a good fix or a workaround on this problem.
What is needed : Draw a background canvas(white), and on top of it I have to draw - Grid(with transparent background), Graph1(with transparent background), Graph2(with transparent background) and whatever else.
What is done : I have all the functions which all work, but only when they aren't ontop of each other.
Problem : Everything I draw with a seperate function has a white background (NOTE: Something.Clear(Color.Transparent); doesn't work, makes the background black.. which really won't help)
So I've found some workarounds how to do completely transparent pictures and I even found some .dll that would suit me BUT it has some nice licence things that won't work for me unfortunately, so I'm back to square one.
[PS. I hope people won't start to flame to look harder on Google or whatever, so all I can say is.. I have and I was unsuccsessful]
|
|
|
|
|
Your browser will display pngs with transparency, I thought. This all sounds a little too difficult to me tho, have you considered using silverlight instead ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
No I haven't.. Guess I'll take a look into it right away
(about the Png, for some reason it didn't even let me save to png.. but I had no problem saving to Gif.. so I'll take a look into that aswell)
|
|
|
|
|
Hello,
I'm not sure if this is the right forum to ask my question, but it involves Flash and .net.
I need to drag small images and place them over a larger image such that they blend well and look like one image. This image then needs to be saved in the database (SQL Server). Later this image needs to be fetched from the db and displayed in the format it was saved earlier. I am new to flash and have no clues how to go about this.
The site is developed in .net and the database used is SQL Server and the above described functionality needs to be developed using Flash/Ajax/Javascript.
Any help would be appreciated.
Thanks.
|
|
|
|
|
So, this is essentially a flash question ? I'd suggest trying the web dev forum, but I'm not sure if this is the right place for Flash questions overall.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I'm trying to build a sitemap so users can follow the path.
My issue is that I can have multiple same landing pages of categories under different industries or products.
Here is a sample of my sitemap:
<siteMapNode url="~/home.aspx" title="Home" description="Home Page">
<siteMapNode url="~/industry.aspx?ztid=0" title="Automotive" description="">
<siteMapNode url="~/productDetails.aspx?catID=16" title="Wire Marker Booklets" />
<siteMapNode url="~/productDetails.aspx?catID=28" title="Cable Marker Dispenser" />
</siteMapNode>
<siteMapNode url="~/industry.aspx?ztid=1" title="Aviation/Aerospace" description="" />
<siteMapNode url="~/productDetails.aspx?catID=1" title="Self-Laminating Labels" />
</siteMapNode>
<siteMapNode url="~/productList.aspx?ztid=0" title="Pre-printed Wire Markers" >
<siteMapNode url="~/productDetails.aspx?catID=16" title="Wire Marker Booklets" />
<siteMapNode url="~/productDetails.aspx?catID=28" title="Cable Marker Dispenser" />
</siteMapNode>
<siteMapNode url="~/productList.aspx?ztid=1" title="Self Laminated Labels" />
<siteMapNode url="~/productDetails.aspx?catID=1" title="Self-Laminating Labels" />
<siteMapNode url="~/productDetails.aspx?catID=16" title="Wire Marker Booklets" />
</siteMapNode>
<siteMapNode url="~/productList.aspx?ztid=2" title="Blank Printable" description="" />
<siteMapNode url="~/productDetails.aspx?catID=1" title="Self-Laminating Labels" />
<siteMapNode url="~/productDetails.aspx?catID=16" title="Wire Marker Booklets" />
<siteMapNode url="~/productDetails.aspx?catID=28" title="Cable Marker Dispenser" />
</siteMapNode>
</siteMapNode>
How could I create this without having to create like
<siteMapNode url="~/productDetails.aspx?catID=28a" title="Cable Marker Dispenser" />
<siteMapNode url="~/productDetails.aspx?catID=28b" title="Cable Marker Dispenser" />
<siteMapNode url="~/productDetails.aspx?catID=28c" title="Cable Marker Dispenser" />
So it won't create an error? Would also not be efficient for programming.
Please advise, I'm also open to other solutions.
Thanks
Thomas
|
|
|
|
|
We have a webservice that seemed to be doing fine until it wasn't - and we are having a @@#$!! of a time figuring out what happened.
We added "better" caching in and were fairly confident it was caching when it was supposed to and expiring when it was supposed to.
The question is: how to do better upfront testing? How do you best go about stress testing your app before it embarasses you?
Thanks.
|
|
|
|
|
There are many tools out there. I have used WebLoad[^] and it worked well for me.
|
|
|
|
|
|