|
What do you want us to do?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Member 2458467 wrote: if (Page.User.IsInRole(Globals.Settings.AppRoles.KhachHang))
There's nothing in the code you've posted to show how you're loading the roles for the user.
If you're not loading the roles, then the user won't be in any roles, and your Page_Load method won't redirect at all.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
If so, why can I login the sql server's user/password ?
protected void btLogon_Click(object sender, EventArgs e)
{
if (Membership.ValidateUser(txtEmail.Text, txtPassword.Text))
{
...
}
else
{
...
}
}
|
|
|
|
|
You can log in, but in the code you've posted, you're not assigning any roles to the user.
Any calls to User.IsInRole will therefore return false .
ASP.NET 3.5 - Roles | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You can log in, but in the code you've posted, you're not assigning any roles to the user.
Any calls to User.IsInRole will therefore return false.
ASP.NET 3.5 - Roles | Microsoft Docs[^]
I don't understand you saying "Any calls to User.IsInRole will therefore return false." Can you tell me where this is ? How do I edit the code? I debug in the button_click event code, I see
protected void btLogon_Click(object sender, EventArgs e)
{
if (Membership.ValidateUser(txtEmail.Text, txtPassword.Text))
{
try
{
if (Request.QueryString["ReturnUrl"] != null)
{
FormsAuthentication.RedirectFromLoginPage(txtEmail.Text, false);
}
else
{
FormsAuthentication.SetAuthCookie(txtEmail.Text, false);
Session["username"] = txtEmail.Text.Trim();
Response.Redirect(Globals.ApplicationPath + "Logon_Redirect.aspx");
}
}
catch (Exception ex)
{
Debug.Print("Error login sql: " + ex);
}
}
else
{
try
{
if (txtEmail.Text==ConfigurationManager.AppSettings["EmailWebmaster"].ToString() && txtPassword.Text == ConfigurationManager.AppSettings["Password"].ToString())
{
FormsAuthentication.SetAuthCookie(txtEmail.Text, false);
Session["username"] = txtEmail.Text.Trim();
Response.Redirect(Globals.ApplicationPath + "Logon_Redirect.aspx");
}
else
lblMsg.Text = ResourceManager.GetString("Logon_False");
}
catch (Exception ex)
{
Debug.Print("Error Web.config: " + ex);
}
}
}
I am debugging both the user/pass sql server and user/pass cases in the Web.config file when I came to the code "Response.Redirect (Globals.ApplicationPath +" Logon_Redirect.aspx ");" In both cases, a notification is sent to view the http://www.mediafire.com/view/wvlg2xymggvd6rj/ErrLoginFA.jpg/file attachment
When running this line with the corresponding user/pass will give an error message Debug.Print (...) corresponding to both cases. If the login user/password sql server can access, the login user/password Web.config cannot access although the login user/password sql server reports the above error via Debug.Print (..)
Error login sql: System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.AbortCurrentThread()
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)
at System.Web.HttpResponse.Redirect(String url)
at webapp4U.UI.Controls.Controls_MenuLeft.btLogon_Click(Object sender, EventArgs e) in c:\WebSite2010\Controls\Logon.ascx.cs:line 68
Error Web.config: System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.AbortCurrentThread()
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)
at System.Web.HttpResponse.Redirect(String url)
at webapp4U.UI.Controls.Controls_MenuLeft.btLogon_Click(Object sender, EventArgs e) in c:\WebSite2010\Controls\Logon.ascx.cs:line 85
|
|
|
|
|
There is nothing in any of the code you've posted that sets the roles for a user.
Computers aren't magic. If you don't tell the system that the user is in a particular role, then it doesn't have any way to know that the user is in that role. When you later ask it if the user is in that role, the only answer it can give you is "no".
Follow the link I provided in my previous message, and read about how to set up your application to support user roles.
(And you can ignore the ThreadAbortException - that's a normal part of redirecting the user to another page.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a RequestorDropDownList which is populated with a list of names from a GetRequestorInfoModel.
I need help to make a change so that when this list is populated, the first name is not automatically selected until a user selects it.
How do I do this based on my code below?
ASP code for the dropdownlist
<asp:DropDownList ID="RequestorDropDownList" runat="server" Font-Size="8.25pt"
Height="20px" ToolTip="Requestor" Width="160px" SelectMethod="GetRequestorEmail"
DataTextField="DisplayName" DataValueField="Email"
OnSelectedIndexChanged="RequestorDropDownList_SelectedIndexChanged">
</asp:DropDownList>
Code behind that is populating the dropdownlist
#region Requestor dropdownlist
public async Task<IEnumerable<GetRequestorInfoModel>> GetRequestorEmail()
{
try
{
var requestors = await FTACaseReseting.Controllers.RequestorInfoController.GetAllRequestorInfoes();
return requestors.OrderBy(x => x.DisplayName);
}
catch (Exception ex)
{
string errorMsg = string.Format("An error has occured in {0}. \nException:\n{1}", "PopulateRequestorComboBox()", ex.Message);
Response.Write("<script>alert(" + HttpUtility.JavaScriptStringEncode(errorMsg, true) + ")</script>");
return Enumerable.Empty<GetRequestorInfoModel>();
}
}
#endregion
Here is code for RequestorDropDownList_SelectedIndexChanged
protected void RequestorDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
if (RequestorDropDownList.SelectedItem ==null)
{
ListItem requestorItem = new ListItem();
requestorItem = (ListItem)RequestorDropDownList.SelectedItem;
if (requestorItem.Text.Length < 0)
{
string selectRequestor = "Please select a Requestor.";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + selectRequestor + "');", true);
}
this.EmailButton.Enabled = false;
RequestorDropDownList.SelectedValue = RequestorDropDownList.SelectedItem.Value;
}
}
modified 9-Jan-20 12:29pm.
|
|
|
|
|
You can add an empty item, such as one that has text "Please select..." or something like that.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I actually have tried to add <--Please Select a Requestor--> but I do not know how to add that text.
Do I add that text message in ASP code for the DropDownList or code behind that is populating dropdownlist? I really do not know how to add it but I want to add it with your help.
When I debug, requestorItem = (ListItem)RequestorDropDwonList.SelectedItem is showing first name on the list. I want it to show null or nothing.
|
|
|
|
|
Member 11403304 wrote: but I do not know how to add that text. Whatever code is creating the list just have it add in the blank one.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
You insert a new object into the first position in the list populating the drop down. You now know what the content of that item is so when you process the selection you check for the inserted item and deal with that.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
My code for EmailButton_Click is not working. I am getting an error System.Net.Mail.SmtpException: 'SSL must not be enabled for pickup-directory delivery methods.' so email is not sent.
How can I fix this?
Here is the code
protected void EmailButton_Click(object sender, EventArgs e)
{
string requestor = RequestorDropDownList.SelectedValue.ToString();
string message = "The following records have been prepped for processing. Valid cases will be processed.";
if (requestor.Length > 0)
message = string.Format(message);
using (MailMessage mailMessage = new MailMessage())
{
mailMessage.From = new MailAddress("NoReply_FTA@courts.state.mn.us");
MailAddress to = new MailAddress("okaymy1112@gmail.com");
mailMessage.To.Add(to);
string ccEmailAddress = "okaymy1112@mail.com";
if (ccEmailAddress.Length > 0)
{
MailAddress ccto = new MailAddress(ccEmailAddress);
mailMessage.CC.Add(ccto);
}
mailMessage.Subject = "FTA Case Reset Notice";
mailMessage.Body = message;
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
smtpClient.PickupDirectoryLocation = @"c:\smtp";
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = true;
smtpClient.Timeout = 60000;
smtpClient.Send(mailMessage);
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('An email has been sent to '" + requestorName + "');", true);
}
|
|
|
|
|
|
The error is self-explanatory. You are using both SSL and a pickup folder, you can't use both. You either send over the network and use SSL, or write to the pickup folder which has no support for SSL. If you want to use the pickup folder don't set EnableSsl to true.
|
|
|
|
|
Can you kindly help or guide me on doing it the way you described? For example based on my code how can I can it so that 1. I can send email over the network and use SSL or 2. write to the pickup folder which has no support for SSL
|
|
|
|
|
The solution depends on if you want to use the pick-up folder or send over the network, something you haven't indicated.
|
|
|
|
|
The code below is from a desktop app that uses forms. I was asked to create a new web app to replace old desktop client app.
How can I change the following code to work in web app which does not have forms instead has aspx?
Please help.
private async void GetCasesButton_Click(object sender, EventArgs e)
{
if (CaseNumbersTextBox.Text.Length < 1)
{
MessageBox.Show("Casenumber textbox cannot be empty.", "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
ComboboxItem requestorItem = new ComboboxItem();
requestorItem = (ComboboxItem)RequestorComboBox.SelectedItem;
ComboboxItem reasonItem = new ComboboxItem();
reasonItem = (ComboboxItem)ReasonComboBox.SelectedItem;
if (requestorItem.Value < 1)
{
MessageBox.Show("Please select a Requestor.", "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (reasonItem.Value < 1)
{
MessageBox.Show("Please select a Reason.", "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string userEnteredCaseNumbers = CaseNumbersTextBox.Text;
userEnteredCaseNumbers = userEnteredCaseNumbers.Replace("\r", ",");
userEnteredCaseNumbers = userEnteredCaseNumbers.Replace("\n", ",");
while (userEnteredCaseNumbers.Contains(",,"))
userEnteredCaseNumbers = userEnteredCaseNumbers.Replace(",,", ",");
List<string> userEnteredCaseNumberList = new List<string>();
userEnteredCaseNumberList = userEnteredCaseNumbers.Split(',').Where(x => x.Length > 0).ToList();
userEnteredCaseNumberList = userEnteredCaseNumberList.Select(s => s.Trim()).ToList();
try
{
int newBatchNumber = await CandidateCaseController.GetNextBatchNumber();
foreach (string caseNumber in userEnteredCaseNumberList)
{
EditCandidateCaseModel newCandidate = new EditCandidateCaseModel();
newCandidate.CaseNbr = caseNumber;
newCandidate.RequestorInfoID = requestorItem.Value;
newCandidate.ReasonID = reasonItem.Value;
newCandidate.BatchNumber = newBatchNumber;
newCandidate.EntryStaffUserName = this._loggedInUserName;
await CandidateCaseController.PostCandidate(newCandidate);
}
List<GetCandidateCaseModel> candidateList = await CandidateCaseController.GetAllCandidates();
candidateList = candidateList.Where(x => x.BatchNumber == newBatchNumber).ToList();
string candidateCasesString = string.Empty;
Regex rgxDash = new Regex("[^a-zA-Z0-9 ,]");
candidateCasesString = string.Join(",", candidateList.Select(p => p.CaseNbr.ToString()));
candidateCasesString = rgxDash.Replace(candidateCasesString, "").ToString();
List<string> smallEnoughStrings = new List<string>();
while (candidateCasesString.Length > 0)
{
int sendLength = 200;
bool isLastString = false;
if (candidateCasesString.Length < sendLength)
{
sendLength = candidateCasesString.Length;
isLastString = true;
}
string smallChunk = candidateCasesString.Substring(0, sendLength);
if (!isLastString)
{
int lastComma = smallChunk.LastIndexOf(',');
smallChunk = smallChunk.Substring(0, lastComma);
candidateCasesString = candidateCasesString.Remove(0, lastComma);
if (candidateCasesString[0] == ',')
candidateCasesString = candidateCasesString.Remove(0, 1);
}
else
candidateCasesString = candidateCasesString.Remove(0, sendLength);
smallEnoughStrings.Add(smallChunk);
}
List<AcceptCaseNumbersModel> mncisDetailList = new List<AcceptCaseNumbersModel>();
List<AcceptCaseNumbersModel> smallEnoughMncisDetailList = new List<AcceptCaseNumbersModel>();
foreach (string smallEnoughString in smallEnoughStrings)
{
smallEnoughMncisDetailList = await FTACaseReset.Controllers.JusticeController.GetAllAcceptCaseNumbers(smallEnoughString);
mncisDetailList.AddRange(smallEnoughMncisDetailList);
}
foreach (GetCandidateCaseModel candidateCase in candidateList)
{
string caseNbrWODash = rgxDash.Replace(candidateCase.CaseNbr, "").ToString();
AcceptCaseNumbersModel mncisDetail = mncisDetailList.Where(x => x.CaseNbrSrch.ToLower() == caseNbrWODash.ToLower()).FirstOrDefault();
if (mncisDetail != null)
{
candidateCase.FirstPenalty = mncisDetail.FirstPenaltyFlag == 1 ? true : false;
candidateCase.SecondPenalty = mncisDetail.SecondPenaltyFlag == 1 ? true : false;
if (candidateCase.CaseNbr.ToLower().Contains("vb") == false)
candidateCase.RejectionReason = await FTACaseReset.Controllers.RejectionController.GetRejectionByDescription(Enumerations.Rejections.No_Records_To_Reset.ToString().Replace("_", " "));
else if (candidateCase.FirstPenalty == false && candidateCase.SecondPenalty == false)
candidateCase.RejectionReason = await FTACaseReset.Controllers.RejectionController.GetRejectionByDescription(Enumerations.Rejections.No_Records_To_Reset.ToString().Replace("_", " "));
if (candidateCase.RejectionReason == null)
candidateCase.RejectionReason = await FTACaseReset.Controllers.RejectionController.GetRejectionByDescription(Enumerations.Rejections.Valid.ToString());
candidateCase.Title = mncisDetail.Style;
await FTACaseReset.Controllers.CandidateCaseController.PutCandidate(candidateCase);
}
else
{
candidateCase.RejectionReason = await FTACaseReset.Controllers.RejectionController.GetRejectionByDescription(Enumerations.Rejections.Invalid_Case_Number.ToString().Replace("_", " "));
await FTACaseReset.Controllers.CandidateCaseController.PutCandidate(candidateCase);
}
}
GetCasesProgressBar.PerformStep();
this.ClearForm();
ValidTabPage.Controls.Clear();
InvalidTabPage.Controls.Clear();
ValidTabPage.Text = "Valid Cases";
InvalidTabPage.Text = "Invalid Cases";
this.PopulateBatchComboBox();
List<GetCandidateCaseModel> thisBatchCasesList = new List<GetCandidateCaseModel>();
thisBatchCasesList = await Controllers.CandidateCaseController.GetCandidateByBatchID(newBatchNumber);
if (thisBatchCasesList.Count > 0)
this.EmailButton.Enabled = true;
else
{
this.EmailButton.Enabled = false;
return;
}
this.PopulateTabs(thisBatchCasesList, true);
this.GetCasesPanel.Visible = false;
this.UpdateExistingPanel.Visible = true;
ComboboxItem batchItem = new ComboboxItem(thisBatchCasesList[0].BatchNumber);
SelectBatch(batchItem);
ComboboxItem requestorUpdateItem = new ComboboxItem(thisBatchCasesList[0].RequestorInfo);
SelectRequestorUpdate(requestorUpdateItem);
ComboboxItem reasonUpdateItem = new ComboboxItem(thisBatchCasesList[0].Reason);
SelectReasonUpdate(reasonUpdateItem);
}
catch (Exception ex)
{
string errorMsg = string.Format("An error has occured in {0}. \nException:\n{1}", "GetCasesButton_Click()", ex.Message);
MessageBox.Show(errorMsg, "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
|
|
|
|
|
No one is going to rewrite all of your code for you and quite frankly, it's very rude for you to ask us to. Converting desktop app to web app is not a trivial task.
Step 1. Learn the basics of web development. How and where code runs can be very different than desktop development.
Step 2. Rewrite the code. Figure out what the code does and then rewrite it for the web.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
ZurdoDev, I was not asking you or anyone to wrote the code for me. Maybe my question could have been rewritten to make more sense. I am working on the app and I will be asking simpler questions as I get stuck. I made a mistake and seems you are offended. That was not my intention to offend you and other or to be rude. Moving forward, I will post better questions. Everyone makes mistakes. I am sure you might agree with me. Accept my sincere apology.
|
|
|
|
|
I was asked to make a new web app based on a desktop client app which uses forms. My question today is, since some of the code I need help with is lengthy, is there a way to add code in my question by attaching a file?
|
|
|
|
|
No, when you ask a question just post the relevant code. It should never be very long.
Post a clear question showing the relevant code and we'll be happy to help.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Hello to everyone!
I need your support in coding that how should I add the speech audio to the paragraph texts/script in web-page by clicking on Read Button it should be played the audio and text should be appeared by type animation based on the audio.
Appreciate having your support in this regards!
|
|
|
|
|
I have not done this before; however, a quick google search gave me this, Add Free Text-to-Speech to Your Site | WebsiteVoice[^]
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Thank you very much for the sharing the link ZurdoDev! I want it a little professional, I have the script and recorded audio and I have problem in coding that how it should be displayed in Web page that audio should be played with script simultaneously or the same time.
|
|
|
|
|
Suppose I have a website written in asp.net and the database is SQL Server, after I "Publish the web site" and I want to encode this code for smartphones (both android and Android operating systems) iphone) what software do I use? Note that I only packaged the code in "Publish web site" and the SQL Server data I still kept on the server (not packing the SQL Server data)
|
|
|
|