|
You already asked this question[^] in the Quick Answers sections. Posting it on several forums will not help you to get a quicker answer; please do not cross-post your questions.
enum HumanBool { Yes, No, Maybe, Perhaps, Probably, ProbablyNot, MostLikely, MostUnlikely, HellYes, HellNo, Wtf }
|
|
|
|
|
This is a very, very, easy problem to solve and only you can do it since we can't run your code. You are trying to access something that is null. Debug your code and you'll find it right away. Simple.
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 VB.Net application using Windows authentication and I would like to implement impersonation. I think that if I can set the value of HttpContext.Current.User to a new username, I can impersonate who ever I wish. Please let me know if this is the correct approach and if so how do I change the value of HttpContext.Current.User.
Thanks in advance.
|
|
|
|
|
|
Apart from what Richard mentioned, I believe you will only mess up with the framework.
Can you share the underlying goals to impersonate the users, so that maybe we can provide you with a better alternative for the approach?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
No, you cannot impersonate that way. That would be a HUGE security hole. Just google asp.net impersonation. It is very easy to do and a couple of ways of doing it. One via web.config and another via code.
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.
|
|
|
|
|
Greetings experts,
When I run my app with the following code:
Private Sub SearchCustomers()
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim startDate As DateTime
Dim EndDate As DateTime
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand()
Dim sql As String = "spGetLogs"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@uuid", suuid.Text)
cmd.Parameters.AddWithValue("@callerlist", caller_list_id.Text)
cmd.Parameters.AddWithValue("@phone", phonenumber.Text)
If DateTime.TryParseExact(date_start.Text, "yyyy-MM-dd HH:mm:ss", Nothing, System.Globalization.DateTimeStyles.None, startDate) Then
cmd.Parameters.AddWithValue("@start", startDate)
Else
cmd.Parameters.AddWithValue("@start", DBNull.Value)
End If
If DateTime.TryParseExact(date_end.Text, "yyyy-MM-dd HH:mm:ss", Nothing, System.Globalization.DateTimeStyles.None, EndDate) Then
cmd.Parameters.AddWithValue("@Endd", EndDate)
Else
cmd.Parameters.AddWithValue("@Endd", DBNull.Value)
End If
cmd.Parameters.AddWithValue("@calltype", call_type.SelectedValue)
'Response.Write(sql)
'Response.End()
cmd.CommandText = sql
cmd.CommandTimeout = 600
cmd.Connection = con
Using sda As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
gvCustomers.DataSource = dt
gvCustomers.DataBind()
End Using
End Using
End Using
End Sub
It just keeps timing out.
However, if I run the query used in the spGetLogs stored procedure to get a count of records, it is only 191,000.
Is there something wrong with the code below?
I will be happy to post the query inside the spGetLogs stored procedure.
I have been thrust into a demo of this app on Monday.
In fact, we went through this with the users a couple of hours ago and now I run into this huge issue.
Any assistance is greatly appreciated.
|
|
|
|
|
All your code does is call SQL. So, no, the problem is not in the code. You'll have to debug your sql to find out why it is slow.
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.
|
|
|
|
|
This may be too late, but …
Try this:
1) Move the Dim dt as New DataTable() before the Using sda statement
2) Move the gvCustomers.DataSouce and Databind statement after the end Using
3) Leave the sda.Fill(dt) inside the Using … end Using block
My theory is that the databinding is taking too long and subsequently the SQL fails because everything is wrapped inside the Using … end Using block.
Just a theory. Give it a shot and post back your results.
|
|
|
|
|
Hi all,
Im looking for information but I dont know if there is a special phase or term to describe it.
Basically, I am building a little Ticketing/Helpdesk system. I do not want to hard code the Questions/Forms. I want an admin to be able to create a Questions/FOrms under a specific Subject.
What should i be searching for to find information on this?
Thanks
Chris
Chris Wright
|
|
|
|
|
This is more a design issue.
You need to store the questions somewhere, usually a database.
You then need to create a form so the admin can create the the questions, storing them in your data store.
You then need to collect the responses for each question and store them in your data store.
After that you have to create the workflow that will support your business requirement.
All of the above can be achieved with winforms and a database. I would probably search for survey or help desk or bug tracking examples.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Thank you for the reply. It gives me an idea of how the stucture needs to be. I need to make sure I get the database right. It's going to be very complex.
Im going to struggle figuring how to separate the data into tables and then link it all back together to display it within the front end.
Chris Wright
|
|
|
|
|
Take a look at http://www.databaseanswers.org/data_models/[^] and see if there is one that meets your needs. It is a good site to study the structures of databases.
And yes put lot of effort into designing your data structure, think through your requirements before you start creating your database.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
In the first DropdownList should display the Countries and in the second should display Cities based on the Country like .. USA then display just cities in USA . well i am getting undefined in dropdown city the Question is why i am getting always undefined in City dropDown list ?
here is countrol :
<pre> public ActionResult Index()
{
Details();
return View();
}
public void Details (
{
var model = db.GetUniversities().ToList();
List<SelectListItem> li = new List<SelectListItem>();
li.Add(new SelectListItem { Text = "Please select Country",Value="0"});
foreach (var item in model)
{
li.Add(new SelectListItem { Text = item.Country, Value = item.Id.ToString()});
ViewBag.state = li;
}
}
[HttpPost]
public JsonResult GetCity (int id)
{
var ddlCity = db.GetUniversities().Where(x => x.Id == id).ToList();
List<SelectListItem> licities = new List<SelectListItem>();
if (ddlCity != null)
{
foreach (var x in ddlCity)
{
licities.Add(new SelectListItem { Text = x.City, Value = x.Id.ToString() });
}
}
return Json(new SelectList(licities, "Text", "Value"));
}
here view
<div class="form-group">
@Html.LabelFor(model => model.Country, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Country, ViewBag.state as List<SelectListItem>, new { style = "width: 200px;" })
@Html.ValidationMessageFor(model => model.Country, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.City, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.City, new SelectList(string.Empty, "Value", "Text"), "--Select City--", new { style = "width:200px" })
@Html.ValidationMessageFor(model => model.City, "", new { @class = "text-danger" })
here jQuery
$(document).ready(function () {
$("#Country").change(function () {
$("#City").empty();
$.ajax({
type: 'POST',
url: '@Url.Action("GetCity")',
dataType: 'json',
data: { id: $("#Country").val() },
success: function (city) {
$.each(city, function (i, city) {
$("#City").append('<option value="' + city.Value + '">'+ city.Text + '</option>');
});
},
error: function (ex) {
alert('Failed.' + ex);
}
});
return false;
})
});
|
|
|
|
|
You may have to set an ID attribute to your DropDownListFor control so you can reference them in your jQuery code. For example:
@Html.DropDownListFor(model => model.Country, ViewBag.state as List<SelectListItem>, { @id="ddlCountry", @class="YourCSSClassName" })
then in your jQuery, you can access it like this:
$("#ddlCountry").change(function () {
});
|
|
|
|
|
i am still getting the same error .. where should i exactly write the id .. could you more explain please
i thank you very much in advanced
|
|
|
|
|
You need to give ID's to all your controls that you reference in your jQuery and then use the IDs just like what I demonstrated. If you followed that and you are still getting error, then post your updated code here and show us which line you are getting the error.
|
|
|
|
|
Hi Vincent,
so i am still getting the same problem thus let me show you what i have changed .
i did what you have told me . could you check once again and in SQL there are some Countries and Cities like USA -> Bosten , Germany -> Frankfurt etc....
the View :
<div class="form-group">
@Html.LabelFor(model => model.Country, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Country, ViewBag.state as List<SelectListItem>
, new {@id ="ddlCountry", @class = "form-control" })
<div class="form-group">
@Html.LabelFor(model => model.City, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.City, new SelectList(string.Empty, "Value", "Text"), "--Select City--",
new {@id ="ddlCity", @class = "form-control" })
The jQuery :
$(document).ready(function () {
$("#ddlCountry").change(function () {
$("#ddlCity").empty();
$.ajax({
type: 'POST',
url: '@Url.Action("GetCity")',
dataType: 'json',
data: { id: $("#ddlCountry").val() },
success: function (city) {
$.each(city, function (i, city) {
$("#ddlCity").append('<option value="' + city.Value + '">'+ city.Text + '</option>');
});
},
error: function (ex) {
alert('Failed.' + ex);
}
});
return false;
})
});
and with Controls haven't changed :
public void Details ()
{
var model = db.GetUniversities().ToList();
List<SelectListItem> li = new List<SelectListItem>();
li.Add(new SelectListItem { Text = "Please select Country",Value="0"});
foreach (var item in model)
{
li.Add(new SelectListItem { Text = item.Country, Value = item.Id.ToString()});
ViewBag.state = li;
}
}
[HttpPost]
public JsonResult GetCity (int id)
{
var ddlCity = db.GetUniversities().Where(x => x.Id == id).ToList();
List<SelectListItem> licities = new List<SelectListItem>();
licities.Add(new SelectListItem { Text = "--Select City--", Value = "0" });
if (ddlCity != null)
{
foreach (var x in ddlCity)
{
licities.Add(new SelectListItem { Text = x.City, Value = x.Id.ToString() });
}
}
return Json(new SelectList(licities, "Text", "Value"));
|
|
|
|
|
What error are you getting now? Still undefined? Please be specific also for the errors that you are currently getting.
|
|
|
|
|
it's fine now . i have got it .
i thank you a lot
|
|
|
|
|
That's great! Glad to be of help!
|
|
|
|
|
Hello,
This issue occurs when a request process with "&" char (URL With "&").
e.g.
http://PSL.com/CALCC&test&Calendar2018_AR.pdf
Our requirement is to allow URL With "&" request using HTTP modules in IIS.
We don't want to modify web.config file for resolving this issue.
Means validation request=false in web.config. We need to solve this issue using HTTP module.
Need your suggestion on this issue.
Thanks,
Yuvraj
|
|
|
|
|
|
Thanks for replay. Please suggest for handle this issue using HTTP Module class.
|
|
|
|
|
Hello;
I have 2 different class libraries (data model, business services) in my solution. There is an app config file in the data model. I wonder if I can read it inside of business services? (the error is configuration manager does not exist.)
I can add values into web config which is in the web API project in this solution but this time I need to add web API project in the reference of business services. It gives a circular dependency error.
|
|
|
|
|