hi,
I am using a create user wizard that has been personlized to capture address and other data.
There is also a file upload control that accepts MP3
In web config I specified maximum of 20MB
if the user uploads large file they will be redirected to Error page with a warning.
I have set up this using Global Asax file and method as below
private const int MyMaxContentLength = 1000; //Wathever you want to accept as max file.
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.HttpMethod == "POST"
&& Request.ContentLength > MyMaxContentLength)
{
Response.Redirect("~/errorFileTooBig.aspx");
}
}
The created user has an event as below.
If the user uploads a larger file and is redirected to error page ---- how can I be sure that asp.net membership is not activated
and new user is added to the system?
The reason is I want the user to be able to return to the form again and
use the same User Name and Email of first attempt.
aspx
<asp:LinkButton ID="StepNextButton" class="btn btn-success" CausesValidation="True" CommandName="MoveNext" ValidationGroup="signup" runat="server"><i class="fa fa-check-circle"></i> Submit my profile >> </asp:LinkButton>
Created User Event
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
MembershipUser newUser = Membership.GetUser(CreateUserWizard1.UserName);
Guid UserGUID = (Guid)newUser.ProviderUserKey;
TextBox FirstName = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("FirstName");
TextBox Surname = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Surname");
TextBox Email1 = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Email");
TextBox Mobile = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Mobile");
DropDownList CountryCode = (DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("CountryCode");
TextBox Address = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Address");
TextBox Address2 = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Address2");
TextBox Town = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Town");
TextBox City = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("City");
TextBox Postcode = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Postcode");
DropDownList CountryDDL = (DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Country");
InsertArtist.InsertParameters["FirstName"].DefaultValue =
FirstName.Text.ToString();
InsertArtist.InsertParameters["LastName"].DefaultValue =
Surname.Text.ToString();
InsertArtist.InsertParameters["Email"].DefaultValue =
Email1.Text.ToString();
InsertArtist.InsertParameters["Mobile"].DefaultValue =
CountryCode.SelectedValue.ToString() + Mobile.Text.ToString();
InsertArtist.InsertParameters["Bio"].DefaultValue = ArtistBio.Text.ToString();
InsertArtist.InsertParameters["StageName"].DefaultValue =
StageName.Text.ToString();
InsertArtist.InsertParameters["Website"].DefaultValue =
Website.Text.ToString();
InsertArtist.InsertParameters.Add("ArtistId", UserGUID.ToString());
InsertArtist.Insert();
// First Audio File Upload
FileUpload File1 = (FileUpload)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Audio2");
if (File1.HasFile)
{
string fileExt = System.IO.Path.GetExtension(File1.FileName);
if (fileExt == ".mp3" )
{
const string PhotoDirectory = "~/Audio/";
string brochurePath = PhotoDirectory + File1.FileName;
string fileNameWithoutExtension =
System.IO.Path.GetFileNameWithoutExtension(File1.FileName);
int iteration = 1;
while (System.IO.File.Exists(Server.MapPath(brochurePath)))
{
brochurePath = string.Concat(PhotoDirectory, fileNameWithoutExtension,
"-", iteration, ".mp3");
iteration++;
}
// Save the file to disk and set the value of the brochurePath parameter
File1.SaveAs(Server.MapPath(brochurePath));
Audio0.InsertParameters.Add("ArtistId", UserGUID.ToString());
Audio0.InsertParameters.Add("Url", brochurePath.ToString());
Audio0.InsertParameters.Add("Name", SongName2.Text.ToString());
Audio0.Insert();
}
}
{
Response.Redirect("http://xxxxxxxxxxxxxcom/pending.aspx");
}
}