|
Solution is for .net 2.0
Add these lines to the web.config
<authentication mode="Forms">
<forms name="AuthCookie" path="/" loginUrl="login.aspx" protection="All" timeout="30" defaultUrl="test2.aspx">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
the authorization is used to prevent the anonymous user. in this example my default url is text2.aspx page
In login page write the following code in the button click event
if (ValidateUser())
{
FormsAuthentication.RedirectFromLoginPage(txtuserName.Text, false);
}
ValidateUser() is user-defined function where you will write the code to check whether the password given my user matches with the password available in the database.
In other page's nothing is needing to write for validation
|
|
|
|
|
Hi,
I am getting the below exception when i am trying to sort my webpage or select nextpage in my application.Here is the error details.Need help urgently.
The state information is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The state information is invalid for this page and might be corrupted.
Source Error:
[No relevant source lines]
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\va.admin\ae19a4a9\2ea09e75\App_Web_jb2ohxsj.10.cs Line: 0
Stack Trace:
[SerializationException: The constructor to deserialize an object of type 'Ext.Javascript.JSObject' was not found.]
System.Runtime.Serialization.ObjectManager.GetConstructor(Type t, Type[] ctorParams) +2320401
System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context) +99
[SerializationException: The constructor to deserialize an object of type 'Ext.Javascript.JSObject' was not found.]
System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context) +239
System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder) +44
System.Runtime.Serialization.ObjectManager.DoFixups() +167
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +203
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +190
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) +12
System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +1713
System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +384
System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +198
System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +384
Srikanth Pothineni
|
|
|
|
|
|
hi,
i'm new to programming(ASP.NET), but i tried to launch 1 site i.e www.bhatiarocks.somee.com, but every time its gives me msg "Directory Listing Denied,This Virtual Directory does not allow contents to be listed."
as i told u i'm new to language, so do send me any suggestion in very laymen language.
Thanks in advance
ashish bhatia(er.ashishbhatia@gmail.com)
Ashish Bhatia
|
|
|
|
|
YOu shoud give the site a default page!
Open iis manager and find your site,then right click and find the document tab,set it!:->:->
▒〓〓〓〓〓▒▒〓▒〓▒▒
▒〓▒▒▒▒▒〓〓〓〓〓▒
▒〓▒▒▒▒▒▒〓▒〓▒▒
▒〓▒▒▒▒▒〓〓〓〓〓▒
▒〓〓〓〓〓▒▒〓▒〓▒▒
|
|
|
|
|
I really appreciate if you help me. I have the following rtequriements for Login page. Here I don’t know how to encrypt the password that matches the encrypted password in database and how to sets security cookie.
I really appreciate for your help.
Login Page
Purpose Authenticates User credentials(username/Password) and grants or denies access to the system
Inputs IPaddress, Username, Password, Click on Login button
Processing Make sure User is from an authorized host(IP) address. Verify that User’s Username exist and that the password(encrypted before comparison) matches the encrypted password in database. Sets security cookie (encrypted Userid)on Successful login
output Random web page or URL if the IP address is invalid.After three failed attempts prompt User to notify Administrator. After Successful login , send User to the welcome page.
I have the following table in database which has user name and Password.
UserName Password
1 jbarrera jb
2 nbawa nb
3 testread346567 testrrtyhrttrr
4 testedit test
5 goofy disney
6 mickey disney
|
|
|
|
|
Use
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword,"md5"); or
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword,"sha1");
to encrypt the password.I don't know how to sets security cookie.
|
|
|
|
|
Hi everyone ,is there an easy way to create a button to export my dynamic data into a word Doc?
or pdf ?
Thanks
|
|
|
|
|
Hope this and this can help you.
-------------------------
Listen up! Teamwork means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
Has anyone had any trouble with concatenation with the new 2.0 framework. Here is the scenerio. We are migrating our site from 1.1 to 2.0 and I am working out some bugs and found this to really funny.
UnitStr += sdr("UnitID")
UnitStr is defined a string and sdr("UnitID") is pulled from the database as an integer. In the 1.1 framework(VS2003) it allows it to conncatenate but the 2.0(VS2005) it gives me a "input string is invalid", "Conversion from string "" to type 'Double' is not valid.". The funny thing it shows as an integer in the table and when you watch the variable.
Any one have any ideas?
Keep putting the pieces of the puzze together. Thats a programmer!@
|
|
|
|
|
try using &= instead of +=
--------------------------------------------------
Play Nation States and join The Code Project region with the password: byalmightybob
|
|
|
|
|
I'd say not to use EITHER....look for String concatenation memory c# in google.
The suggestion is to use the StringBuilder class....
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Yeah. Good call.
--------------------------------------------------
Play Nation States and join The Code Project region with the password: byalmightybob
|
|
|
|
|
I want to generate pdf from the htmlstream.I have a third party tool pdfconverter which takes the html stream and generate the pdf.I want to capture the current webpage request and take its html stream and pass it to the pdfconverter so that the page as it is can be converted to the pdf.I am using VS 2005.Any help is appreciated.
Nirmala
|
|
|
|
|
In the page load event try:
Request.InputStream.
Ben
|
|
|
|
|
Here is my code
Stream receiveStream = Request.InputStream;
PdfConverter pdfConverter = new PdfConverter();
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
pdfConverter.PdfDocumentOptions.UseMetafileFormat = true;
pdfConverter.PdfDocumentOptions.ShowFooter = false;
pdfConverter.PdfDocumentOptions.ShowHeader = false;
pdfConverter.LicenseFilePath = Server.MapPath(@"~/Bin");
byte[] downloadBytes = pdfConverter.GetPdfBytesFromHtmlStream(receiveStream, Encoding.UTF8);
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", "binary/octet-stream");
response.AddHeader("Content-Disposition", "attachment; filename=" + "Rendered.pdf" + "; size=" + downloadBytes.Length.ToString());
response.Flush();
response.BinaryWrite(downloadBytes);
response.Flush();
response.End();
I am getting this error
Message = "Could not get the HTML file from the string. A generic error occurred in GDI+.."
if I use the uri to create the request and get the stream and pass it to the pdfconverter
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream();
byte[] downloadBytes = pdfConverter.GetPdfBytesFromHtmlStream(receiveStream, Encoding.UTF8);
It works fine but not when I pass the HttpRequest Page.Request inputstream.Could anyone please correct me and help resolve this.
Thanks
Nirmala
Nirmala
|
|
|
|
|
I try to loop through the controls in the page and to identify certain controls, but I can't locate them.
Here is my code:
Protected Sub submitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitBtn.Click
Dim errMsg As String = ""
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is TextBox Then
errMsg &= "Found it!"
Else
errMsg &= "Nothing Found!"
End If
msgText.Text = errMsg
Next
End Sub
When I trace the ctrl as String output I get ASP.masterpage_master
|
|
|
|
|
Try by the Page.control
Sujit
|
|
|
|
|
Didn't work either, tried that before! (using Masterpage!!!!)
|
|
|
|
|
Found the solution:
Protected Sub submitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitBtn.Click
Dim errMsg As String = ""
Dim ctHolder As ContentPlaceHolder
ctHolder = CType(Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
For Each ctrl As Control In ctHolder.Controls
If TypeOf ctrl Is TextBox Then
errMsg &= "Found it!" & ctrl.ID.ToString() & "<br />"
End If
Next
msgText.Text = errMsg
End Sub
Thanks so for the suggestion!
|
|
|
|
|
I am trying to desn dynamic pages in visual studio. When I go to style and set a background image for the web pages I am designing, my images are not showing up. Whether it is a table cell, layer, or a page background property, its not showing up through the browser only during design mode. anybody know why this is?? I am puzzled. I know it can be done becuase MS has starter templates that look nice but I am trying to desgn my own template.
Any suggestions?
|
|
|
|
|
I'm having a problem. I have put 2 images on the page and was able to see them but but when i run the project I'm unable to see/view my images.
Tranee Developer
|
|
|
|
|
I would guess you forgot to include the images into your project. It is common to in the project create an images directory. Then right click the images dir and add existing items. Once the images are included in your project I would guess they will show up.
hope that helps.
Ben
|
|
|
|
|
Hello
VS 2005
I am using the code below to get and save the connection string in the web.config file. However on the webConfig.Save() line it throws an error:
An error occurred loading a configuration file: Access to the path 'c:\inetpub\wwwroot\Incidents_WS\oa48wsfg.tmp' is denied. (c:\inetpub\wwwroot\Incidents_WS\web.config)
I am not sure what this file is "oa48wsfg.tmp" and why I have access denied.
<br />
Dim cnnString As String<br />
'Get the current connection string<br />
cnnString = WebConfigurationManager.ConnectionStrings("serviceMasterConnectionString").ConnectionString()<br />
cnn.ConnectionString = cnnString<br />
<br />
'Save a new connection string<br />
Dim WebConfig As Configuration<br />
WebConfig = WebConfigurationManager.OpenWebConfiguration("~")<br />
WebConfig.ConnectionStrings.ConnectionStrings("serviceMasterConnectionString").ConnectionString = "data source=steve01\ssd01; database=serviceMaster; user id=sa; pwd=a123"<br />
WebConfig.Save()'Error on this line.<br />
I have gone into the IIS and right click web.config and given read and write permissions. but still get the same error message.
Can anyone please help me with this problem.
Many thanks,
Steve
|
|
|
|
|
Give the proper permissions to the ASPNet user.
|
|
|
|