how to create an ASPNET.mdf file?

M

Mich

Hi,

i'm building an web application for anonymous users. They can take a look in
the website, nothing more. In order to perform other actions, the anonymous
user must be logged. So i create an aspx page with the CreateUserWizard
control. The user can fill his username, password etc ....

My problem is: when an user fills everything and clicks on button "create an
account", nothing happens (no error, but no user account created).
I thought asp.net would create in App_Data an ASPNET.MDF file for storing
user and membership information and add automatically a new connection
string in web.config. But it doesn't happen.

I know i can go in design mode (n VWD) and click on "administer the site",
but all the users are anonymous, so i can't create user in advance.
Do i have to put some configuration code in web.config? Or something else?

Thanks for help
Mich
 
J

Juan T. Llibre

Run aspnet_regsql.exe from a command window in your .Net Framework 2.0 directory.
 
M

Mich

Hi Juan, thanks for replying..

I did this and an mdf file ASPNETDB.MDF was created in the sql server
directory.
So i copied both files (mdf and log) into APP_Data of my application.
I added a connection string in web.config like this:
<add name="aspnetdb" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated
Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

Now, when starting the aspx page containing the createuserwizard and filling
all texboxes, again, nothing happens (user is not created). If i try it
within VWDev., the user is then created.
What do i forget or do wrong?
Thanks
 
D

David

I notice you ahve integrated security rather than user names and passwords.
I may be wrong but I think integrated security will require the current user
to have permission in the database. When you are doing it through VWDev, you
are probably carrying your username through, but when doing it from ASP.NET,
you are using the ASP.NET user account, which may not have permission.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
M

Mich

Account ASPNET has R/W rights on the APP_Data dir.
And if it was not so, i would get an error, but here, no error, nothing
happens ...
 
D

David

but what about your database?

just having access to the directory does not give database permission.

Set up a user in your database. Give that user permission to see the table
you want to view. Put that users username/password into your connection
string.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
M

Mich

David, i did all those things but i found it:
the map security of the standard website in the IIS was set on Windows
Integrated Auth.
The map security of my website (one level lower in the IIS as all other
websites) is set on Anonymous.
This is the reason why login and createuserwizard doesn't work.
I changed the map security of the standard website into Anonymous and
everything works.
Amazing, no?
Do you have an explanation for that?
 
T

Tony Girgenti

Hello Mich.

I'm trying to follow along in this thread beacuse i think i'm having the
same problem.

Can you explain where you went to change your "map security"?

Is it in the IIS Administration?

Any help would be gratefully appreciated.

Thanks,
Tony
 
J

Juan T. Llibre

re:
Can you explain where you went to change your "map security"?

He meant "the mapped security".

Use the IIS Manager for that.
Right-click and select "Properties"; then select the "Directory Security" tab.
 
M

Mich

Yes.

Rightclick on Standard website (maybe diffferent in windows 2003, i use xp
prof.), then take properties and then Map security. There you can choose
anonymous or win. int. auth.
 
T

Tony Girgenti

Hello Mich.

I'm sorry for sounding so stupid but i'm not sure about where to go. By
"Standard website", do you mean "Default Web Site"? I have XP Pro, SP1
also.

Also, after right-clicking and selecting properties, do you mean the
"Directory Security" tab, then click "Edit" for the Authentication Methods
screen? I don't see a "Map secutiry".

Thanks,
Tony
 
J

Juan T. Llibre

re:
!> Also, after right-clicking and selecting properties, do you mean the
!> "Directory Security" tab, then click "Edit" for the Authentication Methods screen?

Yes, he means that.
 
T

Tony Girgenti

Hello Juan.

Well, changing that security settings didn't help me, but thanks for all
your help.

Tony
 
J

Juan T. Llibre

re:
Well, changing that security settings didn't help me, but thanks for all your help.

1. What did you change...and to what ?
2. What happened after you changed it ?
3. Can you restate your problem ? ( Is it different than the OP's problem ? )
 
T

Tony Girgenti

Hello Juan.

I unchecked the "Anonymous access" box on the Authentication Methods screen.
After doing so, nothing changed, so i just figured that it did not help.

My problem is outlined in the next post down.

Thanks,
Tony
 
J

Juan T. Llibre

re:
!> I unchecked the "Anonymous access" box on the Authentication Methods screen.

Hi, Tony.

The OP's problem was solved by *allowing* anonymous access,
not by requiring authentication.

When you *uncheck* the anonymous access box, you are -effectively- *requiring* authentication.

Let's see if we can do a little detective work and find out which account
ASP.NET is running as, so you can assign permissions to the correct account.

First of all, are you using impersonation ?
Knowing that will make a difference.

Secondly, can you save this page and run it from the root directory of your app ?

identity.aspx :
--------------------
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = "ASP.NET is running as the account : " & tmp
End Sub
</script>
<html>
<head>
<title>What account is ASP.NET running as ?</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
---------------------

Whichever account is returned will be the account that needs access permission
to the App_Data directory and database, if you're using a trusted connection,
unless you are using a *specific* account to access your membership database.

Please read through Scott Mitchell's tutorial :

http://aspnet.4guysfromrolla.com/articles/120705-1.aspx

It has invaluable background info which will make your life easier
when trying to implement ASP.NET Membership.
 
T

Tony Girgenti

Hello Juan.

After posting my last rrply to you, i found an article on Google where a guy
said he deleted the login control from the form and recreated it. I tried
that and it worked for me.

I can't explain it but it resolved my problem. Maybe you know why?

Thanks again for all of your help.

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top