In my code I use the tilde to get the app path like so:

 <a href="~/">home</a>

However this results in my link looking like:

<a href="/appname/">home</a>

Is there any way to use the tilde so that it will produce a link without the trailing slash as it is causing unnecessary redirects which is penalising us on seo:

<a href="/appname">home</a>

I tried just "~" but obviously that doesn't work - the best I have come up with is @Url.Content("~/").TrimEnd('/'); but seems a bit daft - surely there is a better way?

so I've looked everywhere for an answer to this peculiar problem, but I couldn't find the exact solution. Lots of similar problems, but not one that solves my exact problem, so apologies if this has already been answered.

I have the following (simplified) model:

public class SimpleModel {
    public List<ListItemModel> Items { get; set; }
}

public class ListItemModel {
     public string Text { get; set; }
     public string Value { get; set; }
     public bool Selected { get; set; }
}

And the following (simplified) view:

@for(var i = 0; i < Model.Items.Count; i++) {
    @Html.CheckBoxFor(
        m => Model.Items[i].Selected,
        new { data_val = Model.Items[i].Value })
    @Html.HiddenFor(m => Model.Items[i].Text)
}

And this produces the expected markup:

<input name="Fields[5].Items[0].Selected" id="Fields_5__Items_0__Selected" type="checkbox" value="true" data_val="89">
<input name="Fields[5].Items[0].Selected" type="hidden" value="false">
<input name="Fields[5].Items[0].Text" id="Fields_5__Items_0__Text" type="hidden" value="Option 1">

And when this is posted to the controller, I receive the following:

  • form-data: "true,false"
  • model.Fields[5].Items[0].Selected: false

I have had to write a method to populate my collection with the data from the form, but I feel that Razor should be taking care of this for me, but it doesn't seem to be working.

What might I be missing?

Thank you

I have a website that has an SSL that I automatically remove the beginning www from when a user visits our site.

So when a user types in www.my-example.com they are redirected to https://my-example.com

Here is the rule I wrote to achieve this.

  <rule name="Remove www.">
    <match url="(.*)" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="^www.(.*)" />
    </conditions>
    <action type="Redirect" url="http://{C:1}/{URL}" />
  </rule>

This works fine in most cases but I'm running into an issue. We have many outside sources linking to individual pages we made like this

https://www.my-example.com/example-post

It correctly removes the www but appends a second / before the example post. So the above url would redirect to https://my-example.com//example-post

I need this to not happen. Any suggestions?

Just in case it's relevant, here is the rule I'm using to force HTTPS

  <rule name="Force HTTPS Redirection" enabled="true" stopProcessing="true">
    <match url="^$" ignoreCase="false"/>
    <conditions>
      <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
      <add input="{HTTPS}" pattern="^OFF$"/>
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/" redirectType="Permanent"/>
  </rule>

I am very new for VB script and Want few attributes from URL.

what i am trying here is :

strUrl = /PACS/Service.svc/PACS/0/95 

The above one is my url. I want to remove 0 and 95.

My code :

If ((Instr(strUrl,"PACS") <> 0)) then
        string[] separateURL = strUrl.Split('?');
            LogToFile separateURL,"place.log"

    end if

But this is not working. Split is correct way or not I am not sure. Any help. Thanks

I am Creating POS system in C# MVC with SQL server database. I want my system to be able to work when No internet and whenever I re connect to the internet, system should be synchronized with live.

I have searched from internet but In all solution they suggested some javascript coding. but i have already created system in C# MVC. So how can i change my existing system to be able to work in offline mode?

Sorry for the confusing title, i'm having trouble trying to explain what I am trying to achieve. I have a view, that currently displays 'Trips' from my database (Destination, Type, Price etc). I then added an extra row to the gridview for radio buttons so that I can select one of the trips. Under the grid view I have placed a button and my aim is to be able to select a trip, click the button and be taken to a 'booking' page. The booking page will display the information for the trip selected, and I will add a drop down list to select the number of people going on the trip.

What is the best way to achieve this? Would a session be viable here? I'm completely new to MVC and am still trying to wrap my head around the way it works! Thanks in advance to anyone who reads this!

GridView

TripController code -

public class TripController : Controller
{
    // GET: Trip
    public ActionResult Index()
    {
        return View();
    }
    public ActionResult List()
    {
        List<Trips> trips = new List<Trips>();
        using (SampleModel dc = new SampleModel())
        {
            trips = dc.Trips.ToList();
        }
            return View(trips);
    }
}

TripsModel code -

[Table("Trips")]
public partial class Trips
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    public int TripID { get; set; }

    [StringLength(50)]
    public string Destination { get; set; }

    [StringLength(50)]
    public string Type { get; set; }

    public int? Price { get; set; }
}

Trip ListView code -

@model List<WebApplication5.Models.DB.Trips>

@{
    ViewBag.Title = "List of trips";
    var grid = new WebGrid(source: Model, canPage: true, rowsPerPage: 10);
    grid.Pager(WebGridPagerModes.All);
}

<h2>List of Trips</h2>

<style type="text/css">
/*Here we will add css for style webgrid*/
.webgrid-table {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1.2em;
    width: 100%;
    display: table;
    border-collapse: separate;
    border: solid 1px #98BF21;
    background-color: white;
}

    .webgrid-table td, th {
        border: 1px solid #98BF21;
        padding: 3px 7px 2px;
    }

.webgrid-header {
    background-color: #A7C942;
    color: #FFFFFF;
    padding-bottom: 4px;
    padding-top: 5px;
    text-align: left;
}

.webgrid-footer {
}

.webgrid-row-style {
    padding: 3px 7px 2px;
}

.webgrid-alternating-row {
    background-color: #EAF2D3;
    padding: 3px 7px 2px;
}
</style>

<div id="content">
@grid.GetHtml(
            tableStyle: "webgrid-table",
            headerStyle: "webgrid-header",
            footerStyle: "webgrid-footer",
            alternatingRowStyle: "webgrid-alternating-row",
            rowStyle: "webgrid-row-style",
            columns: grid.Columns(
                //here i will add column for serial no
                grid.Column(columnName: "TripID", header: "TripID"),
                grid.Column(columnName: "Destination", header: 
"Destination"),
                grid.Column(columnName: "Type", header: "Type"),
                grid.Column(columnName: "Price", header: "Price"),
                grid.Column(format: @<text><input name="radbtn"
                                                  type="radio" value="some 
value" /></text>)
                ))
</div>
<p></p>
<p><input type="submit" value="Book" /></p>

What I am trying to achieve - My application is simply ASP .Net Core application. It is not Web API. I want to execute method before every post/get request from my app to external sources, for example: I am sending a post request, to check SSL expiry date to some website API and it returns me a response. According to the response I am sending another request or not. I don't want to place call method statement before every request, I would like to do it globally.

I was trying to achieve this based on http://www.sulhome.com/blog/10/log-asp-net-core-request-and-response-using-middleware

As it occurs, this middleware works(I have it working) only for internal requests(routing requests inside application).

Is there any possibility to do it for all requests?

Thanks in advance

I am using telerik:RadAutoCompleteBox as a input element.I want to set its value from javascript on the click event of the another button.The code for the element is as follows:

<telerik:RadAutoCompleteBox
         runat="server"
         ID="costCodeTxt"
         Width="400"
         OnClientRequesting="requesting"
         DropDownWidth="300"
         InputType="Text"
         TextSettings-SelectionMode="Single"
         OnClientTextChanged="VerifyJobCostCode">
               <WebServiceSettings Path="~/QuantitySurvey/CostCode.asmx" Method="GetCostCodeList" />
</telerik:RadAutoCompleteBox>

I am trying to use model binding from query parameters to an object for searching.

My search object is

[DataContract]
public class Criteria 
{
  [DataMember(Name = "first_name")]
  public string FirstName { get; set; }
}

My controller has the following action

[Route("users")]
public class UserController : Controller 
{
  [HttpGet("search")]
  public IActionResult Search([FromQuery] Criteria criteria)
  {
    ...
  }
}

When I call the endpoint as follows .../users/search?first_name=dave the criteria property on the controller action is null. However, I can call the endpoint not as snake case .../users/search?firstName=dave and the criteria property contains the property value. In this case Model Binding has worked but not when I use snake_case.

How can I use snake_case with Model Binding?

My application is an ASP.NET Core 1.0 Web API. If my controller returns a small string, everything works fine. But if the string length gets longer than 32768, i'm getting the following error message:

--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Htpp.Frame`1.<RequestProcessAsync>d__2.MoveNext()
Request Information
RequestID:440ed7db-0002-006f-742e-a28f82000000
RequestDate:Tue, 21 Mar 2017 11:30:40 GMT
StatusMessage:Bad Request
ErrorCode:PropertyValueTooLarge

This is my Controller:

[HttpGet]
[Produces("plain/text")]
public async Task<IActionResult> GetData()
{
    return this.Ok(this.GetResponse());
}

private string GetResponse()
{
    string retVal = string.Empty;
    for (int i = 0; i < 32769; i++)
    {
        retVal = retVal + "a";
    }
    return retVal;
}

The full error message:

Microsoft.WindowsAzure.Storage.StorageException: BadRequest
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__4`1.MoveNext() in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Windows Runtime\Core\Executor\Executor.cs:line 315
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter`1.GetResult()
   at MyProjectNameLogging.AzureStorageLoggingConnector.<WriteToRequestLogAsync>d__4.MoveNext() in AzureStorageLoggingTable.cs:line 29
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.GetResult()
   at MyProjectNameLogging.Repositories.RequestLoggingRepository.<WriteToLogAsync>d__6.MoveNext() in Repositories\RequestLoggingRepository.cs:line 36
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.GetResult()
   at MyProjectNameLogging.Middleware.RequestMiddleware.<Invoke>d__2.MoveNext() in Middleware\RequestMiddleware.cs:line 69
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Swashbuckle.SwaggerUi.Application.SwaggerUiMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Swashbuckle.SwaggerUi.Application.RedirectMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Swashbuckle.Swagger.Application.SwaggerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.<Invoke>d__8.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Hosting.Internal.RequestServiceContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace previous location where exception was thrown ---
   at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Htpp.Frame`1.<RequestProcessAsync>d__2.MoveNext()
Request Information
RequestID:6d8afaf4-0002-00cd-1235-a2421e000000
RequestDate:Tue, 21 Mar 2017 12:24:57 GMT
StatusMessage:Bad Request
ErrorCode:PropertyValueTooLarge

I would like to return strings way longer than 32768.

Any advices?

We have been using Okta in one of our applications running on ASP.Net MVC and are using Okta Sign-In Widget.

We did a security audit on our application and it pointed out a vulnerability saying, "Login Credentials Sent as Clear Text".

Upon looking into the network activity, I realised that it does in fact send credentials as clear text.

Our site is already on SSL but we want the credentials to be encrypted as well.

Can someone please guide how we can fix these with the Okta Sign-In Widget?

I am trying to stop the user to enter a numerical value in the search criteria text box when the Dropdown value is MBID The code works I only need help on how to resolve the validation issue

enter image description here

C# Code

protected bool searchData()
{
      string val = DropDownList1.SelectedItem.Value;
 switch (val)
  {
      case "MBID":

       using (SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["Molecular"].ConnectionString))
         {
             con.Open();
               using (SqlCommand cmd = new SqlCommand(@"SELECT  count(*)

                        from Patient  where MBID = @SearchCriteria ", con))
                {

                        DataTable dt = new DataTable();
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        int userCount = (Int32)cmd.ExecuteScalar();
                        da.Fill(dt);
           }
       }

    }

  }

I cannot used the code below because numerical value can be entered for the other option of the dropdown

<asp:TextBox ID="txtSearchCriteria" runat="server />
<asp:CompareValidator ID="cv" runat="server"     ControlToValidate="txtSearchCriteria" Type="Integer"
  Operator="DataTypeCheck" ErrorMessage="Value must be an integer!" />

No matter what I do the following code does not seem to work. It always breaks at ExecuteNonQuery().

Anything I am missiong?

Always throws

System.InvalidOperationException: 'Operation is not valid due to the current state of the object.'

protected void Submit_Click(object sender, EventArgs e)
{
    if (Page.IsValid)
    {
        OracleConnection conn = new OracleConnection(connectionString);
        int room_id = Int32.Parse(DropDownList2.SelectedValue);
        int activity_id = Int32.Parse(DropDownList1.SelectedValue);
        string session_code = TextBox1.Text;
        int start_time = GetTimeSeconds(startTime.Text);
        int period = GetTimeSeconds(duration.Text);
        string book_date = bookDate.Text;
        string ref_no = DropDownList3.SelectedValue;

        conn.Open();

        using (OracleCommand cmd = new OracleCommand(
            "insert into BRAZESH.ALL_SESSION(SESSION_CODE,START_TIME,\"PERIOD\",BOOKED_DATE,ROOM_ID,ACTIVITY_ID,REF_NO)" +
            " values ('" + session_code + "'," + start_time + "," + period + ",to_date('" + book_date + "', 'yyyy-mm-dd')," + room_id + "," + activity_id + ", '" + ref_no + "')"))
        {
            try
            {
                cmd.ExecuteNonQuery();
            }catch (OracleException ex)
            {
                throw ex;
            }
        }

    }
}

I have existing ng2 asp.net 4.6 project. Right now I am using systemjs,but I want to migrate to the webpack (that is new hot thing, isn't?:) )

I can't find asp.net 4.6 guide for webpack..or any asp.net project where I could find the correct setup.

Do you know any guides or github projects where I could learn about webpack setup in asp.net 4.6 environment?

I found webpack + asp.net 4.6 tutorial http://developer.telerik.com/featured/webpack-for-visual-studio-developers/

but it doesn't cover ng2 setup Thanks

I try to put the plugin blueimp to my Asp.Net MVC application. My upload target is about 1GB. How to handle chunk file upload fle in server side?

I currently have websites running on MONO 4.8.0 and Ubuntu 16.04.2 LTS using ASP.NET, Entity Framework and SQLite. There is however a problem that the CPU randomly starts capping at 100% after a day or two of use, on random websites, and sometimes even on websites that haven't been JIT compiled. Several other users have the same problem but nobody has any solution.

Now that .NET Core is out, and considering my websites are only basic ASP.NET, with a little bit of SQLite, perhaps switching over to .NET Core would be an option and it would resolve the problem.

First, any drawbacks I should know about .NET Core?

Second, if I do the switch, I must know what I'm doing as the server will be down while I try to figure it out, so I'd rather ask for the exact steps ahead of time.

I suppose I have to uninstall MONO first, then install .NET Core, to avoid conflicts, or can it be done the other way around? Any steps to make .NET Core active?

Then the websites are configure like this... what needs to change here?

<VirtualHost *:80>
  ServerName www.website.com
  ServerAlias website.com
  DocumentRoot /var/www/website

  Redirect permanent / https://www.website.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName website.com
  ServerAlias www.website.com
  DocumentRoot /var/www/website
  DirectoryIndex default.aspx index.aspx index.php index.html

  <IfModule mod_mono.c>
    MonoServerPath website.com "/usr/bin/mod-mono-server4"
    MonoApplications website.com "/:/var/www/website"
  </IfModule>

  <Location "/">
    Allow from all
    Order allow,deny
    <IfModule mod_mono.c>
    MonoSetServerAlias website.com
    SetHandler mono
    </IfModule>
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
  </Location>

  SSLEngine on
  SSLCertificateFile /etc/apache2/keys/www.website.com/website.crt
  SSLCertificateKeyFile /etc/apache2/keys/www.website.com/private.key
  SSLCertificateChainFile /etc/ssl/certs/comodo.bundle

  <Location "/blog">
    SetHandler None
  </Location>
  <LocationMatch ".*\.php">
    SetHandler application/x-httpd-php
  </LocationMatch>
</VirtualHost>

I have merged 6tables with 7th table and when i bind with Gridview i am getting data like below. but i want data to Come side by side.

Below GridView i am getting :

srno   name   FA1 FA2 SA1 FA1 FA2 SA1
1       ABC   1    2   3  
2       XYZ   1    2   3
3       ABC               1    2   3
4       XYZ               1    2   3

I Want my gridview to look like below :

srno   name   FA1 FA2 SA1 FA1 FA2 SA1
1       ABC   1    2   3  1    2   3
2       XYZ   1    2   3  1    2   3

Here is my Sql Query Which runs for 6different subjects store data into datatables and then merge into another datatable.

select f1.FA1 as FA1san,f1.FA1Total as FA1Totalsan,f2.FA2 as FA2san,f2.FA2Total as FA2Totalsan,f3.FA3 as FA3san,f3.FA3Total as FA3Totalsan,f4.FA4 as FA4san,f4.FA4Total as FA4Totalsan,sa1.SA1 as SA1san,sa1.SA1Total as SA1Totalsan,sa2.SA2 as SA2san,sa2.SA2Total as SA2Totalsan from ViewFa1 f1 inner join StudentDetails s on f1.StudentId=s.Id inner join ClassTable c on f1.StudentId=c.StudentId left join ViewFa2 f2 on f1.StudentId=f2.StudentId and f1.SubjectId=f2.SubjectId left join ViewFa3 f3 on f1.StudentId=f3.StudentId and f1.SubjectId=f3.SubjectId left join ViewFa4 f4 on f1.StudentId=f4.StudentId and f1.SubjectId=f4.SubjectId left join ViewSa1 sa1 on f1.StudentId=sa1.StudentId and f1.SubjectId=sa1.SubjectId left join ViewSa2 sa2 on f1.StudentId=sa2.StudentId and f1.SubjectId=sa2.SubjectId order by s.FirstName

I have written a following code to perform an XML request using .NET's HttpWebClient library like this:

 public async Task<string> DoRequest()
        {

            using (var httpClient = new HttpClient())
            {
                string requestXML = "My xml here...";
                var request = new HttpRequestMessage(HttpMethod.Post, "example.com");
                request.Content = new StringContent(requestXML, Encoding.UTF8, "text/xml");
                var response = await httpClient.SendAsync(request);
                return await response.Content.ReadAsStringAsync();
            }
        }

And in the main function of the console application:

 Klijent test= new Klijent();
 var res = test.DoRequest();

But the res return type is always showing me this:

Id = 1, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"

How do I actually perform the request with this library? What am I doing wrong here??

I need to integrate FB Webhook with my mvc .net project so that I can fetch user's real time data and do some clustering on them. I am really clueless how to receive response from FB. Any help on this topic??

(I have been at this problem for about 6 months now, so please forgive me if anything about this question does not fit Stack Overflow's guidelines. I'm pretty sure I'm ok though. I knew there was a chance of this being too vague, I just wasn't sure.)

Long story short: I have been tasked with improving an absolute demon of an asp.net web application that was developed in 2001. The original programmer did not use a single ASP html object, but instead opted to print ALL html, javascript, and css via Response.Write(). All of the .aspx pages are, quite literally, blank - everything is done in the aspx.cs.

Here is an example of what I'm working with, and what 90% of the codebehind looks like:

if (Common.IsSuperuser())
{
Response.Write("<div style=\"float:left;padding:5px 5px 5px 25px;\">");
Response.Write("<form action=\"users.aspx?id=" + strUserID + "&siteid=" + thisSite._siteGUID + "\" method=\"post\" style=\"display:inline;\">");
Response.Write("<input type=\"hidden\" name=\"isClearEmpty\" value=\"true\" />");
Response.Write("<input type=\"submit\" name=\"clearEmptyAccounts\" value=\"Clear Empty Users\" />");
Response.Write("</form>");
Response.Write("</div>");
}

Please end me.

One of the major goals is to reduce page load times, which are currently sitting between 4 and 8 seconds. However, when I set two breakpoints at the '{' and '}' of the page_load() function, the time elapsed between them is only ~475ms for any given .aspx page. Where is the other 3500-7500ms coming from?

According to Chrome's console, that time is spent simply waiting for the server. We host dozens of web stores on one server (50+), each store is its own ASP.NET application in it's own directory, and furthermore each store's admin component is also it's own ASP.NET application within it's respective store's directory. Each store/admin combo also has it's own Microsoft Access (yes, you read that right) database. It is, frankly, insane.

The kicker is that the actual store application loads just fine, but the admin side application is always plagued with >5s load times. We also quite often get a plaintext response "Server Too Busy" while on the admin application, but never on the client side store. (Literally zero other information, just a blank, white HTML page that says "Server Too Busy")

Our stores are hosted on a virtual semi-private server by a third party, so let's rule out server settings and hardware for now, as I do not have the ability to change these things. I'm just wondering if there is anything I can do within the boundaries of the application itself to alleviate our administrators' frustrations while I rewrite the entire thing from the ground up.

If there is anything that anyone can suggest, great, I'll try it. If I'm limited by my inability to control server settings, or by the vagueness of this question (I have no more information to go on, sorry), that's fine too.

Thank you all for your time!

I have middleware used for authentication purposes and need to distinguish users by the type if they are internal or external. After this I want to redirect external users to custom error page, because they should not have access to particular section of my site.

I wanted to throw HttpResponseException with my custom status code and handle it by linking in web config's section customErrors with my error page. However I cannot use custom status code this way and to use one of the existing codes is bad idea in my case.

To be honest I am quite new to OWIN middleware and I am not even sure what to google. I will be most grateful for hints how to solve such situation.