|
Why have you replied to me instead of the OP?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: instead of the OP? Maybe he's not down with OPP?
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.
|
|
|
|
|
Good question. It wasn't intentional.
Perhaps lack of sleep, woke up at 4:30 and could not go back to sleep, so I went to work.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I know how to get it in Startup, but I wrote a class that seeds the database with values, and expanded it to write the product images to wwwroot from the database called SeedDatabase. I just need the wwwroot so I can write the images to the right place.
Guess I figured it out...
Amazing, had no idea this would work, well in development at least.
So I can request services from startup? That's my new question.
private static void SeedDatabase(IWebHost host, Settings appSettings, bool isDocker, string env)
{
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
var logger = services.GetRequiredService<ILogger<Program>>();
var environment = services.GetService<IHostingEnvironment>();
logger.LogInformation("DbAuthConnection=" + appSettings.MongoDB.Connection);
logger.LogInformation("DbAuthContainer=" + appSettings.MongoDB.Container);
logger.LogInformation("Environment=" + env);
try
{
DbInitializer.SeedData(appSettings, environment, isDocker);<br />
logger.LogInformation("Seed DB Succeeded:" + DateTime.Now);
}
catch (Exception ex)
{
logger.LogError(ex, "Seed DB Failed on " + DateTime.Now + ":" + ex.Message);
}
}
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I have been struggling with this problem for some time. What I need to to identify when this is True.
<p
id="noWorkopportunities" class="text-info" style="display:none;">
No available work opportunities found.
/p>
Here is my source and code. Thank You!!
Jim
<div class="panel panel-primary" style="margin-top:10px;">
<div class="panel-heading">
Work Opportunities Available
</div>
<div class="panel-body">
<img id="pw_workopportunities" src="/Images/pleaseWait.gif" alt="Please Wait" style="margin-left:10px" />
<p id="noWorkopportunities" class="text-info" style="display:none;">
No available work opportunities found.
</p>
<table id="workopportunities" style="display:none;" class="table table-bordered">
<tr>
<th>Project Name/Work Order</th>
' Get all tables in the document
Dim tables As HtmlAgilityPack.HtmlNodeCollection = main.DocumentNode.SelectNodes("//table") <b><---- this statements successfully gets all the tables</b>
Dim rows As HtmlAgilityPack.HtmlNodeCollection = main.DocumentNode.SelectNodes("//p[@id='noWorkopportunities'") <b><---I get an error/nothing</b>
' Iterate all rows in the first table
For k = 0 To rows.Count - 1
-- modified 11-Jan-20 11:47am.
|
|
|
|
|
I am trying to send email using the EmailButton_Click code. However I am getting the error on this line smtp.Send(mailMessage)
The error is System.Net.Mail.SmtpException: 'Cannot get IIS pickup directory.'
Can someone help me fix it please?
protected void EmailButton_Click(object sender, EventArgs e)
{
EmailButton.Visible = true;
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(requestor);
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;
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.Send(mailMessage);
}
string msg = "No batches were found";
Response.Write("<script>alert('" + msg + "')</script>");
}
|
|
|
|
|
This is much the same issue as you posted a couple of days ago below at How to I make EmailButton_Click work? - ASP.NET Discussion Boards[^], and you appear to be trying to learn how to make it work by posting questions one at a time. Can i suggest that you study the SMTP documentation more closely to see exactly how you should be using these features. If you want to use PickupDirectoryFromIis then you most likely need to configure it within IIS.
|
|
|
|
|
First google result has some possible fixes, https://stackoverflow.com/questions/2190361/cannot-get-iis-pickup-directory
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 have a foreach statement. When I run my code in debug mode, I am getting the following error. I am not sure how to fix it. Google search shows may ways of doing it.
Error:
'object' does not contain a definition for 'Value' and no accessible method 'Value' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
My code behind
foreach(string caseNumber in userEnteredCaseNumberList)
{
EditCandidateCaseModel newCandidate = new EditCandidateCaseModel();
newCandidate.CaseNbr = caseNumber;
newCandidate.RequestorInfoID = requestorItem.Value;
newCandidate.BatchNumber = newBatchNumber;
newCandidate.EntryStaffUserName = this._loggedInUserName;
await CandidateCaseController.PostCandidate(newCandidate);
}
|
|
|
|
|
requestorItem does not have a property named Value. That's all the error is telling you.
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 am writing a small example of Login webSite, there are two types of accounts and passwords, one is an account and password is stored in the Web.config file and the other two accounts and passwords are saved in SQL Server database, My problem is that in form 1, when logging in it opens Logon_Redirect.aspx file but cannot access, the following is my code
I am debugging and running to the code where this opens the Logon_Redirect.aspx file but nothing, but when I log in with another account and password (the user password of SQL Server) log in well.
In file Web.config
<appSettings>
...
<add key="SmtpServer" value="localhost"/>
<add key="EmailWebmaster" value="admin"/>
<add key="Password" value="123"/>
...
</appSettings>
In file Logon_Redirect.aspx
...
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
In file Logon_Redirect.aspx.cs
...
public partial class Logon_Redirect : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.User.IsInRole(Globals.Settings.AppRoles.KhachHang))
Response.Redirect(Globals.ApplicationPath);
else if (Page.User.IsInRole(Globals.Settings.AppRoles.Admin))
Response.Redirect(Globals.ApplicationPath + "WebMaster/Contacts/Contact.aspx");
}
}
In file Logon.aspx.cs
protected void btLogon_Click(object sender, EventArgs e)
{
if (Membership.ValidateUser(txtEmail.Text, txtPassword.Text))
{
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");
}
}
else
{
if (webapp4U.BOL.User.CheckUserName(txtEmail.Text) && 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");
}
}
|
|
|
|
|
I am not sure what you want us to do. You have to debug this, we can't do it for you.
And in case you do not know, storing passwords in the web.config is not a good idea nor storing them in the db either. You should store hashes, but that's another topic for another time.
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.
|
|
|
|
|
|
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);
}
|
|
|
|