Is there a way to intercept a HttpPost request to a .asmx WebService using an Attribute?

I already have a SoapExtension that validates what I need for SOAP requests, but I need to do the same validation in POST requests.

Before everyone lights me up about checking Google first or reading the myriad of other posts here and elsewhere about running something from Nuget, adding tags to web.config or anything else, yes, I have searched the interwebs first.

I started having this issue sporadically last week. I can pull a branch from our Stash repo, change some code, and everything will build and run beautifully, and I can pull another branch, change some code, and get this error. It is maddening. I can't seem to isolate it.

I am running VS 2015 with a project using System.Web.Mvc

enter image description here

Any and all help is greatly appreciated. Jax

I have a .Net Web Application built using Visual Studio 2013. The application works fine when debugging through Visual Studio.

I attempted to Publish the application through Visual Studio and got the following error:

2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(2990,5): Error : Copying file obj\Release\Package\PackageTmp\bin\Microsoft.Web.Infrastructure.dll to obj\Release\Package\PackageTmp\obj\Release\Package\PackageTmp\bin\Microsoft.Web.Infrastructure.dll failed. Could not find file 'obj\Release\Package\PackageTmp\bin\Microsoft.Web.Infrastructure.dll'.

I tried looking into the Microsoft.Web.Publishing.Targets file, but could see anything obvious that was wrong.

What is the issue I'm having here and how do I correct it?

Please help me to create a dynamic testimonial with images and text.This code is to complicated for me

I have an issue where I can page the first time with my gridview but when I try to click on the second page, nothing happens. I've been able to pinpoint that it has to do with a JQuery script that is used to tab to the next textbox within my gridview which works like a charm. First, here is the relevant code:

<asp:ScriptManager ID="ScriptManagerDetails" runat="server" ScriptMode="Release"></asp:ScriptManager>
        <script type="text/javascript">
            var g_CurrentTextBox;                
            function applicationLoadHandler() {

            function endRequestHandler() {


            function onTextFocus() {
                g_CurrentTextBox =;
        <asp:UpdatePanel ID="UpdatePanelDetails" runat="server">
            <div class="row" id="ItemResults">
            <asp:GridView ID="gvDetailList" runat="server" CssClass="table table-striped table-bordered table-hover" 
              AutoGenerateColumns="false"  AllowPaging="true" OnPageIndexChanging="gvDetailList_PageIndexChanging" OnRowDataBound="gvDetailList_RowDataBound" Pagesize="25" >
                <PagerStyle CssClass="pagination-ys" />
            <asp:SqlDataSource ID="SqlDetailList" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MyConnectionStr%>"                     

Here is the code behind:

protected void Page_Load(object sender, EventArgs e)
    if (!IsPostBack)

private void BindDetails()
    string strSQL = "SELECT  * FROM TABLE";
    SqlDetailList.SelectCommand = strSQL;
    gvDetailList.DataSource = SqlDetailList;

protected void gvDetailList_PageIndexChanging(object sender, GridViewPageEventArgs e)
    gvDetailList.PageIndex = e.NewPageIndex;

If I remove the script, paging works fine. But I like I said, with the script left in, it only works the first time but not on subsequent pages.

We have an ASP.NET Web Api application which uses OAuth Bearer Tokens for authentication, for which we are trying to implement Request/Response logging.

Basically it works like this:
1. User sends request to "/authenticate" and receives an authentication token
2. User then uses this authentication token for requests to the exposed API methods

For logging requests to the exposed API methods, we use a DelegatingHandler which works perfectly fine.

However, requests made to "/authenticate" are not captured by the DelegatingHandler implementation.

Is there a different approach required for logging requests for tokens?

public abstract class MessageHandler : DelegatingHandler
    protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        var correlationId = Guid.NewGuid();

        var requestInfo = string.Format("{0} {1}", request.Method, request.RequestUri);

        var requestContent = await request.Content.ReadAsByteArrayAsync();

        var context = ((HttpContextBase)request.Properties["MS_HttpContext"]);

        await IncomingMessageAsync(correlationId, request.Method, request.RequestUri, request.Headers, requestContent, 
            context.Request.UserHostAddress, context.Request.IsAuthenticated, context.User.Identity.Name);

        var response = await base.SendAsync(request, cancellationToken);

        byte[] responseMessage;

        responseMessage = await response.Content.ReadAsByteArrayAsync();

        await OutgoingMessageAsync(correlationId, response.StatusCode, response.Headers, responseMessage);

        return response;

    protected abstract Task IncomingMessageAsync(Guid correlationId, HttpMethod requestMethod, Uri requestUri, HttpRequestHeaders requestHeaders, byte[] messageContent, string ipAddress, bool isAuthenticated, string requestMadeByUserName);
    protected abstract Task OutgoingMessageAsync(Guid correlationId, HttpStatusCode statusCode, HttpResponseHeaders responseHeaders, byte[] messageContent);

I'm Developing ASP.Net Web Api. For developing WEB API, Do I need Repository Pattern and Unit Of Work, what are the benefits they have and when can we use them ? suggestions are appreciated.

Im trying to make a custom marker infoBox for the google maps API. For this box i want to use a partial view.

The content of the infobox is stored as an HTML string, E.G: " < p> Hello < /p> "

I've figured out how to get the raw html string from the partial view by using the following:

var content= '@Html.Raw(Html.Action("_statusOptions", "Maps", new { sectorNr = 1, trackNr = 2 }).ToString().Replace("\r\n", ""))';

But as you can see, the sectorNr and trackNr are always 1 and 2 right now.

this code is within a loop, and every loop i has a different sectorNr and trackNr that are stored in javascript variables.

So my question is: how can i use those javascript stored variables in my @Html.Action()?

Full code:

 var locations= [];
@foreach(Track track in Model.TrackList)
    foreach(Sector sector in track.SectorList)
        @:locations.push({ "trackId": "@track.Number", "sectorNr": "@sector.SectorNumber", "GeoLong": "@sector.Longitude", "GeoLat": "@sector.Latitude", "sectorStatus": "@Sector.GetStatusString(sector.Status)", "tramNr": "@sector.GetTramNumber()" })

for (i = 0; i < locations.length; i++) {

    var sectorID = locations[i].sectorNr;
    var trackID = locations[i].trackId;

    var lat = locations[i].GeoLat;
    var long = locations[i].GeoLong;

    var sectorStatus = locations[i].sectorStatus;
    var tramNr = locations[i].tramNr;
    latlngset = new google.maps.LatLng(lat, long);
    var theIcon = getMarkerIcon(sectorID, sectorStatus);

    var marker = new google.maps.Marker({
            map: map,
            title: sectorID,
            position: latlngset,
            icon: {
                anchor: new google.maps.Point(10, 10),
                url: theIcon

        var content= '@Html.Raw(Html.Action("_statusOptions", "Maps", new { sectorNr = 1, trackNr = 2 }).ToString().Replace("\r\n", ""))';

        var infowindow = new google.maps.InfoWindow()

        google.maps.event.addListener(marker, 'click', (function (marker, content, infowindow) {
            return function () {
      , marker);
        })(marker, content, infowindow));


I've created an Html Helper extension (so I can write in my Razor markup @Html.XXXX() and spit out html code) and it's not displaying my data that I pass for the asp-items attribute.

Here's my helper:

    public static HtmlString UpdateStartersBlock(this IHtmlHelper helper, int weightClass, int currentWrestler, SelectList selectList)
        return new HtmlString(string.Format(UpdateStartersFormat, weightClass, currentWrestler, selectList));

And here's the Html that I want it to render:

<div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3\">
    <div class=\"card\">
        <div class=\"card-header\">
            <div class=\"row\">
                <div class=\"col-xs-12\">
                    <div class=\"pull-xs-left\">
                        <div class=\"red-bold-22\">{0}</div>
                    <div class=\"pull-xs-left margin-left-10\">
                        <select class=\"form-control\" asp-for=\"{1}\" asp-items=\"{2}\"></select>

When this renders, it just displays an empty dropdown. When I put a breakpoint in the code, I can see that my list of items that gets passed to the selectList parameter ARE populated, so why aren't they being displayed on the page?

Here's the WORKING version where I bypass the Html Helper:

    <div class="col-xs-12 col-lg-6 col-xl-4">
        <div class="card">
            <div class="card-header">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="pull-xs-left">
                            <div class="red-bold-22">125</div>
                        <div class="pull-xs-right margin-left-10">
                            <select class="form-control" asp-for="@Model._125" asp-items="@(new SelectList(Model.RosterWrestlers, "WrestlerId", "WeightRankLastNameFirstName"))"></select>

This is how I tried it, where it doesn't work:

@Html.UpdateStartersBlock(133, Model._133, new SelectList(Model.RosterWrestlers, "WrestlerId", "WeightRankLastNameFirstName"))

As part of a web accessibility exercise, our site is being picked up for some missing form labels

The text areas are areas we do not wish to have labels against (the site is ASP.NET MVC/Razor using jQuery)

@Html.TextAreaFor(x => x.UserInput.FeedbackContent)

Is the correct approach is this scenario to create a corresponding LabelFor and hide it?

@Html.LabelFor(x => x.UserInput.FeedbackContent, new {@class = 'hidden'})

Many thanks

I have a computer which is running scada software, the computer is having a static ip. i want to access the computer using static ip and should be able to view the screen. just like remote access. Can any one give me tips and instructions how to achieve this

I use my application server (PHP) to send firebase notifications to android, it is working fine when I use httpclient from android to send the notification, but when use the same logic from ASP.NET to send parameters the the PHP page the notification is not received, although I get the same response from the server like from the android app:


here is my c# code that is not sending the notification yet a success response is received from firebase:

    protected void Page_Load(object sender, EventArgs e)
    NameValueCollection data = new NameValueCollection();
    data.Add("title", "T");
    data.Add("body", "B");
    data.Add("icon", "Info");
    WebClient client = new WebClient();
    client.Encoding = Encoding.UTF8;
    byte[] response = client.UploadValues("http://*******.com/gcm/down1.php", "POST", data);
    string s = client.Encoding.GetString(response);

any idea how to make it work?

I will be using the same partial across many different pages and the only thing that will be different is reference to the model (@model ...). I tried using "@model dynamic" so I can reference model in view, however lambdas that are in my partial that are referencing specific properties are throwing the following error:

"An expression tree may not contain a dynamic operation"

caused by the following reference to model:

@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })

How do structure my code or create a model reference that will work dynamically so that I can reference each specific model instance in my view pages? I tried many solutions online and nothing has worked so far. Below is my partial and view. Any help would be greatly appreciated!!!


@model dynamic

@using (Html.BeginForm())
<div class="container creative-containter-top">
    <div class="row">
        <div class="col-sm-offset-2 col-sm-8">
            <div class="form-horizontal">
                <div class="panel panel-primary">
                    <div class="panel-height pane panel-heading text-center">
                    <div class="panel-body">
                        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                        @Html.HiddenFor(model => model.Id)

                        <div class="form-group">
                            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })

                        <div class="form-group">
                            @Html.LabelFor(model => model.Code, htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.Code, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Code, "", new { @class = "text-danger" })

                       <div class="form-group">
                            @Html.LabelFor(model => model.Code, htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.Code, new { htmlAttributes = new { @class = "checkbox center-block" } })
                                @Html.ValidationMessageFor(model => model.Code, "", new { @class = "text-danger" })

                        <div class="form-group">
                            <div class="col-md-offset-2 col-md-10">
                                <input type="submit" value="Save" class="btn btn-primary" />

                    <div class="panel-footer">
                        @Html.ActionLink("Back to List", "Index")


@model CreativeNamingConvention.Models.Domain.CreativeOps

ViewBag.Model = Model;
ViewBag.Title = "Edit Creative Ops Field";

@Html.Partial("~/Views/Templates/editBody.cshtml", Model)

How to do client-side validation to validate a selected item?

I have a DropDownList in .Net MVC3 Razor with the user role information. The role can be SuperAdmin(RoleId=1), Operator(RoleId=2) and Viewer(RoleId=3).

Now I want to deprecate Operator. How to do client side validation so that when the user edits his user information, the page will show validation error if the role is Operator?

This is the UserModel:

// User Role Id    
public int RoleId { get; set; }

/// Supported user roles
public IEnumerable<SelectListItem> SupportedRoles { get; set; }


Html.DropDownListFor(m => m.RoleId, Model.SupportedRoles)

The expected behavior is that, for a user with Operator role, when he edits his user information, he cannot save his changes unless he changes his role from Operator to other role.

I don't want to remove Operator from SupportedRoles for an Operator user because if we do so, then when an Operator user updates other fields but does not update role, most likely his role will be changed to a default role and the user is not aware of that.

I read the answers from MVC Model validate Selected Item. RangeAttribute does not work for my case because the RoleId for Operator is in the middle of other RoleIds.

I have an MVC (Razor) web app. The form has 2 fields, one dropdown box (Kendo) and one input field for a date.

After the user makes a change on the dropdown, my 2nd input field is enabled or disabled based on the chosen type in the dropdown box. When the input field is disabled I fill the input with a default value.

When the user submits the form, I only get 2nd form field value posted in the viewmodel when the 2nd field is enabled, when disabled the value is not posted. I know this a common pattern in HTML, that disabled fields are not part of the POST.

My question: how can I solve this issue to get the value POSTed when the field is disabled ? It should be done in JS...

This question already has an answer here:

Well, @Symbol in MVC razor is use for rending the Html elements. I have a situation as under

<label>Result:</label> 34 *10

The output will be 34*10

But If I do

<label>Result:</label>@(34 *10)

The output is 340.

My question is, why without @(..) the output is only a string and with @(...) it gave the calculated one?

NB.~ This might be a very basic question, but I am a newbie..

Thanks in advance.

I have created a web service in c# using framework 3.5 it works fine when requested by Soap UI but does not work with client Tool which they are using. So, what I want is how can I log the request xml coming from client at IIS level. so, that I can check whether the client request is hitting my service or not and can log the request. How can I achieve this? thanks in advance.

This must be the easy one but I've been exploring for some days about how to change a row value clicking on a CheckBox. What I want is to change the value of a column clicking on the CheckBox and keep the CheckBox checked if it is true. Otherwise it will remain unchecked if false. Below is a screenshot and when Public Post column value of a row is 'No', then the CheckBox will remain unchecked. And when I check the CheckBox, then vice-verse means it will remain checked and value will be 'Yes'.

enter image description here

I am not sure how to do it exactly and seen some of the problems or links that deals with this situation:

ASP.NET MVC submitting form on checkbox click

How can I get CheckBox to maintain checked state across postback in ASP.NET MVC?

But I would like to have some more advanced ideas to implement it as it is totally different from ASP.NET Web Form. I would appreciate if experts share some ideas or helpful links to understand. Thanks.

By the way, following is the class that I am working with and I am not sure how to handle the postback from controller.

public class Product
    public int Id { get; set; }
    [Required(ErrorMessage = "Details can't be blank")]
    public string Name{ get; set; }
    public string Date_Posted { get; set; }
    public string Time_Posted { get; set; }
    public string Time_Edited { get; set; }
    public string Date_Edited { get; set; }
    public string Public { get; set; }
    public double Price { get; set; }
    public int User_Id { get; set; }
    public bool Status { get; set; } //This is bit column that I am trying to change and not sure how to handle this from controller
    public List<List> allLists;
    public IEnumerable<List> Items;
    public Pager Pager;

As I was trying to create and edit using single view and on the same controller,the error was coming while managing ID. I was able to manage it while EDITING by :

@Html.HiddenFor(m => m.ID)

but while creating(ADDING) a record I was not able to get ID [ ERROR : The ID field is required ] .The error came while checking :


as I was able to manage ID by using :

  [Bind(Exclude = "ID")]

but again this will create an issue while editing

i have added an image in header . i added jpg,png,bmp file , but its not rendering in browser. while right clicking and clicking the view image its showing like this


The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /CrystalImageHandler.aspx

I've made a simple ASP.NET Core website based on tutorial on website here.

Now, I'd like to publish it on my other machine on the IIS.

I've followed the instructions on this site but I just can't get it working...

I keep getting 500 Internal server error

Based on the logs in Event Viewer this is the culprit:

Failed to start process with the commandline 'dotnet .\MyWebApp.dll'. Error code = '0x80004005'.

Can anyone please help me?