|
I Was running a Fortify scan and I received the error (Poor Error Handling: Overly Broad Catch). Here is the code:
try
{
if (!string.IsNullOrEmpty(xsdFilePath))
{
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(null, xsdFilePath);
XDocument xdoc = XDocument.Parse(xmlString);
xdoc.Validate(schemas, (o, e) =>
{
msg += e.Message + Environment.NewLine;
});
}
if (msg != "")
throw new Exception(msg);
}
catch (Exception e)
{
WriteErrorLog("Error in ValidateXml");
LogError(e);
msg = e.Message;
return "Error - Document is invalid: " + msg;
} <pre>
Simple I thought. I just the "catch (Exception e)" to "catch (ArgumentOutOfRangeException e)". Now when I run the application it receive the follow error:
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
Does anyone know what the problem is?
Thanks,
Steve Holdorf
|
|
|
|
|
I'm just taking a guest here,
But the e in exception is an object
And I think the message is an object as well.
So when passing e to a function, you have to pass it as an exception object
When writing the message in e, you have to extract the message text, or do something with the message object.
|
|
|
|
|
Hi,
I am using gridviewfix in my project and using sorting number there is problem in sorting number.. for example It shows(1,10,100,1000) instead of (1,2,3,4,5..etc). Kindly update me anyone know this answer thanks in advance
|
|
|
|
|
Somehow you are sorting the string value in stead of the int value
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hello
I have asp.net mvc web application. and now i have requirement for json based service for the same mvc application.
So I am thinking to create web api in the same project, Is this right way or can anyone tell me best way because service need for device as well.
|
|
|
|
|
You could do that, or just call actions on controllers and have them return Json data.
|
|
|
|
|
But that data would be then wrapped in HTML layout adding overhead data.
That is why API is better because it simply returns the data and not the HTML DOM itself.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Not when you return Json, as I said in my post
|
|
|
|
|
Totally right, just go ahead. Include the assemblies for Web API and create the controllers for API (using ApiController base class) and you're done.
Just a few other things to get done a left, such as WebApiConfig.cs etc.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
i have issue while calculating addition of Grid control which has adding rows at run time.
|
|
|
|
|
And are we supposed to guess what the issue is? Put me down for "out of cheese error on line 42".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
elaborate more and add your code, error details something here..
modified 20-Sep-20 21:01pm.
|
|
|
|
|
guestUser cannot access the authenticate webpage and i tried web.config and rolebased authentication using weborms but both are not working?
using Request.IsAuthenticated && !string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]) its working but after logining user if i click same link its redirecting to login webpage.
Anyone give suggestions in this?
|
|
|
|
|
|
I sort of need to calculate the average of all the averages in a report.
I have no clue how to do this, but I do have data.
Do I have enough data here to do this, and perhaps some help with the formula
I saw a couple of examples, but wow it looked so complex.
http://study.com/academy/lesson/calculating-weighted-average-method-formula-example.html[^]
If (sCIR.Length > 0) Then
For idx As Integer = 0 To sCIR.Length - 1
rs_DataRow = rs_Table.NewRow()
rs_DataRow(0) = sCIR(idx).FITEMNO
rs_DataRow(1) = sCIR(idx).FDESCRIPT
rs_DataRow(2) = sCIR(idx).FSHIPQTY
rs_DataRow(3) = sCIR(idx).FCOST
rs_DataRow(4) = sCIR(idx).FPRICE
rs_DataRow(5) = sCIR(idx).FAMOUNT
rs_DataRow(6) = sCIR(idx).FMARGIN_PERCENT
rs_DataRow(7) = sCIR(idx).FMARGIN_PROFIT
'Add up the total cost value
m_totalCost += sCIR(idx).FCOST * sCIR(idx).FSHIPQTY
'Add up the total price value
m_totalPrice += sCIR(idx).FPRICE * sCIR(idx).FSHIPQTY
'Calculate the average margin of all the items
'm_avgMarkup +=
'Add up the total margin value
m_totalMargin += sCIR(idx).FMARGIN_PROFIT
rs_Table.Rows.Add(rs_DataRow)
Next
End If
|
|
|
|
|
It just sounds like you need the information about how many items are sold and at what price; then the math is pretty straight forward.
(The sum of all (Item*Price))/Total numbers of items
PS. You are not looking for the weighted sum, unless you don't know how many items are sold. But then your math can't be done.
|
|
|
|
|
Hi, you can get the average by doing this:
m_avgMarkup += sCIR(idx).FMARGIN_PERCENT /idx
below is the whole code,
If (sCIR.Length > 0) Then
For idx As Integer = 0 To sCIR.Length - 1
rs_DataRow = rs_Table.NewRow()
rs_DataRow(0) = sCIR(idx).FITEMNO
rs_DataRow(1) = sCIR(idx).FDESCRIPT
rs_DataRow(2) = sCIR(idx).FSHIPQTY
rs_DataRow(3) = sCIR(idx).FCOST
rs_DataRow(4) = sCIR(idx).FPRICE
rs_DataRow(5) = sCIR(idx).FAMOUNT
rs_DataRow(6) = sCIR(idx).FMARGIN_PERCENT
rs_DataRow(7) = sCIR(idx).FMARGIN_PROFIT
'Add up the total cost value
m_totalCost += sCIR(idx).FCOST * sCIR(idx).FSHIPQTY
'Add up the total price value
m_totalPrice += sCIR(idx).FPRICE * sCIR(idx).FSHIPQTY
'Calculate the average margin of all the items
'm_avgMarkup += sCIR(idx).FMARGIN_PERCENT /idx
'Add up the total margin value
m_totalMargin += sCIR(idx).FMARGIN_PROFIT
rs_Table.Rows.Add(rs_DataRow)
Next
End If
hi
|
|
|
|
|
That's a point in the right direction.
I'll try something similar to that.
If (sCIR.Length > 0) Then
Dim idx As Integer = 0
For idx = 0 To sCIR.Length - 1
rs_DataRow = rs_Table.NewRow()
rs_DataRow(0) = sCIR(idx).FITEMNO
rs_DataRow(1) = sCIR(idx).FDESCRIPT
rs_DataRow(2) = sCIR(idx).FSHIPQTY
rs_DataRow(3) = sCIR(idx).FCOST
rs_DataRow(4) = sCIR(idx).FPRICE
rs_DataRow(5) = sCIR(idx).FAMOUNT
rs_DataRow(6) = sCIR(idx).FMARGIN_PERCENT
rs_DataRow(7) = sCIR(idx).FMARGIN_PROFIT
'Add up the total cost value
m_totalCost += sCIR(idx).FCOST * sCIR(idx).FSHIPQTY
'Add up the total price value
m_totalPrice += sCIR(idx).FPRICE * sCIR(idx).FSHIPQTY
'Calculate the average margin of all the items
m_avgMarkup += sCIR(idx).FMARGIN_PERCENT
'Add up the total margin value
m_totalMargin += sCIR(idx).FMARGIN_PROFIT
rs_Table.Rows.Add(rs_DataRow)
Next
m_avgMarkup = m_avgMarkup / idx
End If
|
|
|
|
|
Hi,
I want to fetch data from SQL database, and display the same on my HTML page in table format using Angular JS.
I am able to get the data in the scope variable, but it is not getting displayed in the HTML page.
Please check the code that I have written below, and help me fixing the issue.
Thanks in advance.
HTML code:
<!DOCTYPE html>
<html>
<head>
<title>:: View Logs ::</title>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular.min.js"></script>
<!--<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>-->
<script src="Scripts/logsController.js"></script>
<script src="Scripts/jquery-2.1.1.js"></script>
<script src="Scripts/jquery-2.1.1.min.js"></script>
<!--<script>
ViewLogsApp = angular.module('ViewLogsApp', []);
ViewLogsApp.controller('ViewLogsController', function ($scope, $http) {
$http.get('data.json').success(function (response) {
$scope.myData = response;
});
});
</script>-->
</head>
<body>
<div ng-app="ViewLogsApp">
<div ng-controller="ViewLogsController">
<table class="table table-striped">
<tr>
<th>Log ID</th>
<th>User Type</th>
<th>User Name</th>
<th>Email ID</th>
<th>Action Type</th>
<th>Section Name</th>
<th>Section Details</th>
<th>DateTime</th>
<th>User IP</th>
</tr>
<tr ng-repeat="item in logslist">
<td>{{item.LogID}}</td>
<td>{{item.UserType}}</td>
<td>{{item.UserName}}</td>
<td>{{item.EmailID}}</td>
<td>{{item.ActionType}}</td>
<td>{{item.SectionName}}</td>
<td>{{item.SectionDetails}}</td>
<td>{{item.DateTime}}</td>
<td>{{item.UserIP}}</td>
</tr>
</table>
</div>
</div>
</body>
</html>
logsController.js code:
angular.module('ViewLogsApp', [])
.controller('ViewLogsController', [
'$scope', function ($scope) {
$scope.logslist = [];
$scope.load;
$scope.load = function () {
$.ajax({
type: 'GET',
contentType: 'application/json; charset=utf-8',
url: 'UserActivityLogs.aspx/getList',
success: function (data) {
$scope.logslist = data
$scope.$apply();
}
});
}
$scope.load();
}
]);
WebMethod code:
[System.Web.Services.WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static List<UserActivityLogsList> getList()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = _connstr;
con.Open();
var logs = new List<UserActivityLogsList>();
string get = "select * from UserActivityLogs";
//string get = "sp_employee";
SqlCommand cmd = new SqlCommand(get, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
UserActivityLogsList e = new UserActivityLogsList();
e.LogID = Convert.ToInt32(dr[0]);
e.UserType = Convert.ToString(dr[1]);
e.UserName = Convert.ToString(dr[2]);
e.EmailID = Convert.ToString(dr[3]);
e.ActionType = Convert.ToString(dr[4]);
e.SectionName = Convert.ToString(dr[4]);
e.SectionDetails = Convert.ToString(dr[4]);
e.DateTime = Convert.ToString(dr[4]);
e.UserIP = Convert.ToString(dr[4]);
logs.Add(e);
}
con.Close();
return logs;
}
Clouds come floating into my life, no longer to carry rain or usher storm, but to add color to my sunset sky. ~Rabindranath Tagore
|
|
|
|
|
I have applied following css to dropdownlist.In chrome browser applied css are reflecting but in mozilla css are not reflecting. I also want to do text of dropdownlist in center align so how to do this? Please anyone guide me?
css are as follows..
border-color:blue;
border-width:2px;
border-top-left-radius:10px;
border-top-right-radius:10px;
border-bottom-left-radius:10px;
border-bottom-right-radius:10px;
-moz-border-radius-bottomleft:10px;
-moz-border-radius-bottomright:10px;
-moz-border-radius-topleft:10px;
-moz-border-radius-topright:10px;
-moz-border-radius:10px;
-webkit-box-align:center;
text-align:center;
|
|
|
|
|
|
|
Hi all,
I have a question regarding hiding of a label and a textbox on a page based on AD group membership (I only want members of the AD group to view and use the ASP control)
So I have the following within my Page_Load Sub
Dim ITContactLabel As Label = DirectCast(FormView1.FindControl("ITContactLabel"), Label)
Dim ITContactTextBox As TextBox = DirectCast(FormView1.FindControl("PRJ_ITContactTextBox"), TextBox)
If (User.IsInRole("MyDomain\My_AD_Group_X") <> "true") Then
' hide the ITContact label
ITContactLabel.Style("visibility") = "hidden"
ITContactTextBox.Visible = "false"
End If
And it works fine when the page is first loaded, but after I hit the update link, the label and textbox become visible.
I have tried to define an OnClick event in my code, but not having success hiding the label and textbox:
Protected Sub UpdateButton_Click(sender As Object, e As System.EventArgs)
in html:
<asp:linkbutton id="UpdateButton" runat="server" causesvalidation="True" onclick="UpdateButton_Click" commandname="Update" text="Update">
I'm thinking it may have something to do with checking the AD group membership, but not sure, any help would be appreciated.
|
|
|
|
|
Try moving that code to FormView1.DataBound Event. If it does not solve your issue post your entire page_load function and your UpdateButton_OnClick event.
|
|
|
|
|
this is all of my code behind:
Partial Class MyPage
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
hiddenID.Value = Convert.ToInt16(Request.QueryString("id"))
Dim LoginLabel As Label = DirectCast(FormView1.FindControl("CurrentUserLogin"), Label)
LoginLabel.Text = HttpContext.Current.User.Identity.Name
If (User.IsInRole("MYDOMAIN\MyADGroup1") <> "true") Then
Response.Redirect("~/AccessDenied.aspx")
End If
Dim ITContactLabel As Label = DirectCast(FormView1.FindControl("ITContactLabel"), Label)
Dim ITContactTextBox As TextBox = DirectCast(FormView1.FindControl("PRJ_ITContactTextBox"), TextBox)
If (User.IsInRole("MYDOMAIN\MyADGroup_X") <> "true") Then
' hide the ITContact label
ITContactLabel.Style("visibility") = "hidden"
ITContactTextBox.Visible = "false"
End If
End Sub
Protected Sub UpdateButton_Click(sender As Object, e As System.EventArgs)
Dim ITContactLabel As Label = DirectCast(FormView1.FindControl("ITContactLabel"), Label)
Dim ITContactTextBox As TextBox = DirectCast(FormView1.FindControl("PRJ_ITContactTextBox"), TextBox)
If (User.IsInRole("MYDOMAIN\MyADGroup_X") <> "true") Then
ITContactLabel.Style("visibility") = "hidden"
ITContactTextBox.Visible = "false"
End If
End Sub
End Class
|
|
|
|