Solution for directory browsing issue in IIS

(In order to Enlarge images Please Right Click and Open images in New Tab).

 

2

 

dw1

 

Then enable directory browsing as shown in below image

 

mvpskills1

Advertisements

How to check particular url is exist or not with the help of HttpWebResponse ?

(In order to Enlarge images Please Right Click and Open images in New Tab).

 

2

 

Let’s see,

 

How to check particular url is exist or not with the help of HttpWebResponse 

 

[Route(“Check”)]
public HttpResponseMessage Check(string appUrl)
{

//Set as below
appUrl=https://sandippatil.com/Downloads/Training ManualHTML.pdf”;

Uri destURL = new Uri(appUrl);
HttpWebRequest request = HttpWebRequest.CreateHttp(destURL);
request.Method = “HEAD”;
try
{
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
if (response.StatusCode == HttpStatusCode.OK)
{
helpEnabled = true;
}
}
catch (Exception ex)
{
helpEnabled = false;
}
HttpResponseMessage resp;
resp = Request.CreateResponse<bool>(HttpStatusCode.OK, helpEnabled);
return resp;
}

 

If doesn’t exists it will throws an exception as shown in below Image.

sk2

 

Another solution is

var appUrl=”https://sandippatil.com/Downloads/Training ManualHTML.pdf”;

bool urlExists;

WebRequest webRequest = WebRequest.Create(appUrl);
WebResponse webResponse;
try
{
webResponse = webRequest.GetResponse();
urlExists= true;
}
catch //If exception thrown then couldn’t get response from address
{
urlExists= false;
}
HttpResponseMessage resp;
resp = Request.CreateResponse<bool>(HttpStatusCode.OK, helpEnabled);
return resp;

 

Working code in WebAPI controller is

 

[Route(“CheckHelpButtonPermission”)]
public HttpResponseMessage CheckHelpButtonPermission(string appUrl)
{
try
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(appUrl);
webRequest.Method = “GET”;

string responseData = string.Empty;
HttpWebResponse httpResponse = (HttpWebResponse)webRequest.GetResponse();

using (StreamReader responseReader = new StreamReader(httpResponse.GetResponseStream()))
{
responseData = responseReader.ReadToEnd();
helpEnabled = true;
}
}
catch (System.Net.WebException ex)
{
helpEnabled = false;
}

HttpResponseMessage resp;
resp = Request.CreateResponse<bool>(HttpStatusCode.OK, helpEnabled);
return resp;
}

 

DataContext.ExecuteCommand Method in entity framework

(In order to Enlarge images Please Right Click and Open images in New Tab).

 

2

Syntax

public int ExecuteCommand(
	string command,
	params object[] parameters
)

This method is a pass-through mechanism for cases where LINQ to SQL does not adequately provide for a particular scenario.

The syntax for the command is almost the same as the syntax used to create an ADO.NET DataCommand. The only difference is in how the parameters are specified. Specifically, you specify parameters by enclosing them in braces ({…}) and enumerate them starting from 0. The parameter is associated with the equally numbered object in the parameters array.

ExecuteQuery and ExecuteCommand allow you to specify a variable number of arguments for parameter substitution. For example, you can specify the parameters when invoking ExecuteQuery<TResult>:

db.ExecuteQuery<Customer>("select * from dbo.Customers where City = {0}", "London");

And, another example:

db.ExecuteCommand("UPDATE Products SET QuantityPerUnit = {0} WHERE ProductID = {1}", "24 boxes", 5)

 

The following example opens a connection and passes a SQL UPDATE command to the SQL engine.

db.ExecuteCommand("UPDATE Products SET UnitPrice = UnitPrice + 1.00");

 

GCCustContext.ExecuteCommand(@”DELETE FROM InterfaceADT WHERE InterfaceADTId = {0}”, NewId.ToString());

 

swq1

finding which column was sorted and in what order in angular ui.grid

(In order to Enlarge images Please Right Click and Open images in New Tab).

 

2

 

$scope.gridOptions = {
    useExternalSorting: true,
    columnDefs: [
       ...
    ],
    onRegisterApi: function( gridApi ) {
      $scope.gridApi = gridApi;
      $scope.gridApi.core.on.sortChanged( $scope, function(grid, sortColumns){

          // sortColumns is an array containing just the column sorted in the grid
          var name = sortColumns[0].name; // the name of the first column sorted
          var direction = sortColumns[0].sort.direction // the direction of the first column sorted: "desc" or "asc"

          
      });
    }
};