|
Good Afternoon Guys
i have a Web Application that, it has a login Screen. I tried to make sure that a User does not bypass the login Screen on the Page load event i used the following line of code
if (Session.IsNewSession)
{
Response.Redirect("login.aspx");
}
.
to Prevent the user going straight to other pages ,i have successfully used this code
Response.Write("<script> window.history.forward(1);</script>;"); .
to make sure that they dont use back to bypass the Pages. Now if a User can log in and Copy the URL to the Exact page they want it does directly ,
How can i prevent this
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
can you elaborate more the line you written given below
"Now if a User can log in and Copy the URL to the Exact page they want it does directly"
Cheers!!
Brij
|
|
|
|
|
Thanks for your reply.
What i mean is that a User can login with the Correct Credentials. While busy navigating the Site , while login. He might relize that he want to access a Certain page Directly without going through a Login page. while logged in he might copy the URL ,
e.g
http:
So now he will logout and paste this address in the address bar and this will take him to the page without loggin in.
So i want to prevent this
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
did u use session.abandon() at the time of logging out.
Cheers!!
Brij
|
|
|
|
|
Yes i did use Session.abandon(). Let me elaborate more clearer about my Situation.
i have created my Login Page and it was two Buttons and we will look into the button that does login in my login Button i have the Following
protected void btlogin_Click(object sender, EventArgs e)
{
String strusername = txtUsername.Text;
String strPassword = txtPassword.Text;
BLL.BLL obj = new BLL.BLL();
int bl = 0;
try
{
bl = obj.Check_Login(strusername, strPassword);
if (bl == 1)
{
Session["USERNAME"] = strusername;
Response.Redirect("Welcome.aspx", false);
}
else
{
Response.Write("<script language='javascript'>alert('Invalid Login');</script>");
}
}
catch (Exception)
{
Response.Write("<script> alert('ex.Message');</script>");
}
}
Now i have my Business logic that Calls the Function that Calls the function in a Data Access Layer that will call the StoreProcedure.
like this
public int Check_Login(String username, String password)
{
int ans = 0;
DAL.DAL obj = new DAL.DAL();
try
{
ans = obj.Check_Login(username, password);
}
catch (Exception)
{
throw;
}
return ans;
}
and from the DAL i execute my SP like this
public int Check_Login(String Username, String Password)
{
con = new SqlConnection(strconlogin);
cmdselect = new SqlCommand();
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.CommandText = "dbo.prcLoginv";
cmdselect.Parameters.Add("@User_name", SqlDbType.VarChar, 50, "UserName").Value = Username;
cmdselect.Parameters.Add("@U_Password", SqlDbType.VarChar, 50, "UPassword").Value = Password;
cmdselect.Parameters.Add("@Results", SqlDbType.Int);
cmdselect.Parameters["@Results"].Direction = ParameterDirection.Output;
cmdselect.Connection = con;
int res = 0;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
res = Convert.ToInt32(cmdselect.Parameters["@Results"].Value);
con.Close();
}
catch (SqlException)
{
throw;
}
return res;
}
Now all my Pages Contains this Code , excluding the login page
Response.Write("<script> window.history.forward(1);</script>");
if (Session["USERNAME"] == "")
{
Response.Redirect("login.aspx");
}
Well here i was to redirect the Users to the login page if the Session Variable is Empty. Well from the Developement site it works but as i said the User can use a full URL to go to a Certain page.
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi,
how many data store in one Sql database?
|
|
|
|
|
What you are Saying does not make sense.
Try to refrase your question.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Are you asking about the maximum size of database?
Sql server Express edition: 4 GB
Sql Server 2008: 524,272 TB
*jaans
|
|
|
|
|
|
shanthi jothi wrote: how many data store in one Sql database
Lots.
Please ask your question in a way that people can understand, that way you will get a proper answer.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
int day = firstDay.Day + 1;
for (int j = i; j <= i + DaysinMonth; j++, k =(k + 2))
{
1. string a = k.ToString();
2. string s2 = string.Concat("TextBox", a);
3. TextBox myTextBox = (TextBox)FindControl(s2);
4. myTextBox.Text = Convert.ToString(day);
5. day = day + 1;
6. if (day == (int)lastDay.Day + 1)
7. break;
}
On Line No 4 error is "Object Reference is not set to an instence of an object."
|
|
|
|
|
I guess the FindControl in step 3 didn't find the control, hence myTextBox is null. Try debugging and check if the control exists.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
s2 in stop 2 and 3 contains the TextBox id .
I cannot understand whats the problem.
Is the problem can be due to Masterpage.But my all textbox control are in content place holder and i am not using any control from master page.
|
|
|
|
|
Have a look in view source and see what the textbox id really is, then adjust your code accordingly.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi,
I have a small doubt that, i want to create 3 seperate projects for 3 layers for my small web application. In that i dont want to place my BAL and DAL in the App_Code folder but i want to manage 3 seperate layers. So how to do that? Can anyone explain about it.
Its urgent please let me know.
|
|
|
|
|
Samiullah wrote: i dont want to place my BAL and DAL in the App_Code folder
Why not? Its the correct place for them.
Samiullah wrote: Its urgent please let me know.
Only for you, nobody else cares.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
It should be Simple , First Create a Website and add a new Project "Class" DAL and another "Class" BLL and you havea Separate Layers , see how i do it
http://www.codeproject.com/KB/vb/N-Tier_Application_VB.aspx[^]
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Just make a Class Library type project for a layer (define class and function inside it) except UI layer.Add there's dll in the UI layer and use them.
Cheers!!
Brij
|
|
|
|
|
i have a grid view and it has an ID column when i set the ID column visible = false that cell has no value and its empty and if i set the visible = true that cell has value how can salve this problem?
|
|
|
|
|
i have a GridView and radiobutton in that grid view.i want to get the ID's of grid view row that i selected . how can i access to this id?
|
|
|
|
|
Gridview has a property , GridView1.SelectedRow u can use this.
|
|
|
|
|
i have a grid view and it has an ID column when i set the ID column visible = false that cell has no value and its empty and if i set the visible = true that cell has value how can salve this problem
So if i use selected row i dont have any value in it?
|
|
|
|
|
I was wondering how I could draw in a Panel. If I create a Panel like
Panel panel = new Panel();
panel.Width = 1000;
panel.Height = 750;
this.Controls.Add(_panel);
In Windows Forms, I could call the PaintEvent but there is no PaintEvent in asp.net is there? So how do I draw lines and such on a web Panel? Also the Panel control in the windows forms has a location property but the Panel web control does not? How do I specify a location then?
For a windows form I would do something like:
Panel panel = new Panel();
panel.Paint += new PaintEventHandler(panel_Paint);
private void panel_Paint(object sender, PaintEventArgs e)
{
// Create a graphics object for the _panel.
Graphics _g = e.Graphics;
Pen pen = new Pen(Color.Black);
_g.DrawLine(pen, 10, 10, 20, 20);
}
How can I draw in a Web Panel like this?
|
|
|
|
|
In web everything is rendered into HTML. Thus when you are using a panel, it will be rendered into a div.
So, if you want to draw anything, you need to dynamically draw them into a bitmap, and then will need to show the bitmap in the web page.
You can look into the code snipped below on how to draw custom images during page render.
private void CreateHorizontalTextImage(string pstrText)
{
float sngFontSize = 7.5f;
Font objFont;
int intImageHeight = 18;
int intImageWidth = 60;
objFont = new Font("Courier", sngFontSize);
using (System.Drawing.Bitmap bitmap = new Bitmap ( intImageWidth, intImageWidth ))
{
using (System.Drawing.Graphics g = Graphics.FromImage(bitmap))
{
System.Drawing.SizeF objSizeOfTextAsSizeF = g.MeasureString(pstrText, objFont);
float sngWidthOfText = objSizeOfTextAsSizeF.Width;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Rectangle rect = new Rectangle(0, 0, intImageWidth, intImageHeight);
System.Drawing.SolidBrush objBlackBrush = new System.Drawing.SolidBrush(Color.Brown);
g.DrawString(pstrText, objFont, objBlackBrush, 0,2);
}
using (System.IO.MemoryStream objStream = new System.IO.MemoryStream())
{
bitmap.Save(objStream, System.Drawing.Imaging.ImageFormat.Gif);
using(System.Drawing.Image img = System.Drawing.Image.FromStream(objStream))
{
System.Drawing.Bitmap b = new System.Drawing.Bitmap(img.Width, img.Height);
using(Graphics gx = Graphics.FromImage(b))
{
gx.DrawImage(img, new Point(0, 0));
}
SaveGIFWithNewColorTable(b, 16, true);
}
}
}
}
protected void SaveGIFWithNewColorTable(
System.Drawing.Image image,
uint nColors,
bool fTransparent
)
{
if (nColors > 256)
nColors = 256;
if (nColors < 2)
nColors = 2;
int Width = image.Width;
int Height = image.Height;
Bitmap bitmap = new Bitmap(Width,
Height,
PixelFormat.Format8bppIndexed);
ColorPalette pal = GetColorPalette(nColors);
for (uint i = 0; i < nColors; i++)
{
uint Alpha = 0xFF;
uint Intensity = i*0xFF/(nColors-1);
if ( i == 0 && fTransparent)
Alpha = 0;
pal.Entries[i] = Color.FromArgb( (int)Alpha,
(int)Intensity,
(int)Intensity,
(int)Intensity );
}
bitmap.Palette = pal;
Bitmap BmpCopy = new Bitmap(Width,
Height,
PixelFormat.Format32bppArgb);
{
Graphics g = Graphics.FromImage(BmpCopy);
g.PageUnit = GraphicsUnit.Pixel;
g.DrawImage(image, 0, 0, Width, Height);
g.Dispose();
}
BitmapData bitmapData;
Rectangle rect = new Rectangle(0, 0, Width, Height);
bitmapData = bitmap.LockBits(
rect,
ImageLockMode.WriteOnly,
PixelFormat.Format8bppIndexed);
IntPtr pixels = bitmapData.Scan0;
unsafe
{
byte * pBits;
if (bitmapData.Stride > 0)
pBits = (byte *)pixels.ToPointer();
else
pBits = (byte *)pixels.ToPointer() + bitmapData.Stride*(Height-1);
uint stride = (uint)Math.Abs(bitmapData.Stride);
for ( uint row = 0; row < Height; ++row )
{
for ( uint col = 0; col < Width; ++col )
{
Color pixel;
byte * p8bppPixel = pBits + row*stride + col;
pixel = BmpCopy.GetPixel((int)col, (int)row);
double luminance = (pixel.R *0.299) +
(pixel.G *0.587) +
(pixel.B *0.114);
*p8bppPixel = (byte)(luminance * (nColors-1)/255 +0.5);
}
}
}
bitmap.UnlockBits(bitmapData);
this.Response.Clear();
this.Response.ContentType = "image/gif";
bitmap.Save(this.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
Response.End();
BmpCopy.Dispose();
bitmap.Dispose();
}
protected System.Drawing.Imaging.ColorPalette GetColorPalette( uint nColors )
{
PixelFormat bitscolordepth = PixelFormat.Format1bppIndexed;
ColorPalette palette;
Bitmap bitmap;
if (nColors > 2)
bitscolordepth = PixelFormat.Format4bppIndexed;
if (nColors > 16)
bitscolordepth = PixelFormat.Format8bppIndexed;
bitmap = new Bitmap( 1, 1, bitscolordepth );
palette = bitmap.Palette;
bitmap.Dispose();
return palette;
}
Abhishek Sur
|
|
|
|
|
How can I add a bitmap to a panel?
|
|
|
|
|