|
deepthy.p.m wrote: How can i solve that.
Have you looked at the bulk/spam folders? Yahoo might have marked the message as spam.
|
|
|
|
|
but in in.com i didn't get that mail.but in yahoo.com its in the span .How can i send directly to inbox in all accounts.
|
|
|
|
|
deepthy.p.m wrote: its in the span
span?
deepthy.p.m wrote: How can i send directly to inbox in all accounts.
Show us the code you are using for sending mail.
|
|
|
|
|
You can't control how a mail provider decides what is spam, if you could, it would be pointless. Whenever the mail is not arriving, you have an issue with your settings and the mail provider, not an ASP.NET question.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
Credentials of which mail server you are providing i.e. which smtp server you are using for sending mail???
I think it is gmail.
|
|
|
|
|
i use localhost mail server
SmtpMail.SmtpServer = "localhost";
|
|
|
|
|
Actually what we do in such conditions while making some mail sending code. We provide the credentials of our mailserver and then through a mail id of our domain we can send mail to any server whether it is gmail or yahoo.
Just while sending your mail code apply break and catch the exception. You will see that most probably these mails were rejected by the servers on which you are sending the mail.
Which port and emailid you have provided in your code.
|
|
|
|
|
This is because most mail accounts like yahoo, msn ect.. have numerous checks like reverse dns to ensure that the emails being sent to them are coming from a fully qualified domain name. If your local computer doesn't have a fully qualified domain name and does not have a reverse dns setup then you may need to send your mail from a remote email server that has that criteria.
Hope this helps.
|
|
|
|
|
i'm trying to restrict one user to be logged in only once .if he tries to log in to the system using his same username while logged in i want to restrict it , i use the session , and trying to catch if the user is already logged in by setting
this.session[user.usrname]=user.usrname;
but when i try to log in system by using the same username it doesn't give any exception. the session mode is InProc .
|
|
|
|
|
I don't see the code where you try to catch that the user is already logged in, only where you set it ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
You can use Database in this scenarios. When user logged in first time, enter the user id/ user name into the database. And this database should be checked every time when any user logging into the system, if the user id is already there, give a message that 'some one is already logged in with same credentials'.
Note : you have to clear the database entries when user log off the system,close the browser etc.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
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.
|
|
|
|
|