I'm trying to use tagHelper in my practice project but when I run the app I get the error here in image, I'm new to MVC.

ContactViewModel:

public class ContactViewModel
{
    [Required]
    public string Name { get; set; }
    [Required]
    [EmailAddress]
    public string Email { get; set; }
    [Required]
    [StringLength(4096, MinimumLength = 10)]
    public string Message { get; set; }
}

Contact.cshtml:

 @model WebApplication1.ViewModels.ContactViewModel;
@{ 
    ViewBag.Title = "Contact";
}

@section scripts {
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
}
<h1>Contact Me</h1>

<form>
    <label asp-for="Name"></label>
    <input  asp-for="Name"/>
    <label asp-for="Email"></label>
    <input  asp-for="Email"/>
    <label asp-for="Message"></label>
    <textarea cols="40" rows="4" asp-for="Message"></textarea>
    <div>
        <input type="submit" value="Send Message"/>
    </div>
</form>

what i'm doing wrong?

My android application is posting to an asp.net web server using volley.

I want to make sure one user cannot post on another's behalf. My POST goes to some backend logic and then manipulates values on an MSSQL Server tied to that specific user. All sensitive information on the SQL side is encrypted.

My users log in through google sign in.

When I post to the web server, what can I include in my post params to be sure a fraudulent POST is not sent on another user's behalf?

I have [ChildActionOnly] in my Controller called _AllLinks

I can use RenderAction if _AllLinks.cshtml is in my Controller Directory but I cannot use it if i try to put it in a different directory in VIEWS folder such as the following

Html.RenderAction("_AllLinks", "Home", new { Model = Model, Area = "Core/List/" });

Where Location of _AllLinks.cshtml is Views/Core/Lists/

How can i call Html.RenderAction if PartialView called _AllLinks is in a different folder?

Cheers

EDIT

public ActionResult Index()
        {

            return View();
        }

        [ChildActionOnly]
        public ActionResult _AllLinks(List<Models.Links.MLink> Model)
        {
            return PartialView("~/Views/Core/Lists/_AllLinks", Model);
        }

I have a drownlist with an onchange event which I want to send a data which I charge, this in turn brings null

<div class="col-sm-4">
  <div class="form-group">
    <label class="control-label">PaĆ­s</label>
    @{
      var attrHTMLUniNegocio = new Dictionary<string, object>(attrHTML);
      attrHTMLUniNegocio.Add("onchange", "clickMe(this, 'idPais', '" + Url.Action("GetPlanesDDL", "PaisCat") + "')");
      attrHTMLUniNegocio.Add("onchange", "LoadDependentDDL(this, 'NombreDepartamento', '" + Url.Action("GetPlanesDDL", "DepartamentoCat") + "', true, 'showSelect')");
    }

    @Html.RenderDDLDinamicList("PaisCat", () => Model.NombrePais, null, null, attrHTML, true)

  </div>
</div>


<script type="text/javascript">

  function clickMe() {
    var stateId = $('#PaisCat').val();
    alert('Click: ' + stateId );
  }

</script>

My model has a DisplayFormat set as shown in image below

[BsonElement("spread")]
[BsonRepresentation(BsonType.Decimal128,AllowTruncation =true)]
[DisplayFormat(DataFormatString = "{N6}")]
public decimal Spread { get; set; }

In my view I have the following code:

<tbody>
    @for (int i = 0; i < Model.Entries.Count; i++)
    {
        <tr>
            <td>
                @Html.DisplayFor(item => item.Entries[i].Spread)
            </td>

Still, when the page loads, I get the error:

FormatException: Input string was not in a correct format. System.Text.StringBuilder.FormatError() System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, string format, ParamsArray args) string.FormatHelper(IFormatProvider provider, string format, ParamsArray args) Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.TemplateBuilder.Build() Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.GenerateDisplay(ModelExplorer modelExplorer, string htmlFieldName, string templateName, object additionalViewData) Microsoft.AspNetCore.Mvc.Rendering.HtmlHelperDisplayExtensions.DisplayFor(IHtmlHelper htmlHelper, Expression> expression) AspNetCore._Views_Dashboard_Bordao_cshtml+d__30.MoveNext() in Bordao.cshtml + @Html.DisplayFor(item => item.Entries[i].Spread)

I tried changing the formatString to "0.000", "N6".. Still no success.. If outside the view code I run string.format(spread, "N6"), I get the correct result.

How can I get my view to format my decimal values with 6 decimal places. Thanks

I am using http://container.thephpleague.com as my Dependency Injection Container. I am making project in MVC and I am trying to not break MVC pattern.

I am loading Database, Json, etc. classes from DI Container (defined before routing, etc.), but I need models for every controller. Is this right way how to load Models with their own dependencies inside Controller?

Controller:

abstract class Controller
{
    protected $di;
    protected $db;
    protected $latte;
    protected $json;
    //etc...

    public function __construct(League\Container\Container $container, array $args)
    {
        $this->di = $container;
        $this->db = $container->get('database');
        $this->json = $container->get('json');
        //etc...

        $this->args = $args;

        $this->setup();
    }
}

class ApiController extends Controller
{
    function setup()
    {
        $this->model = new ApiModel($this->di);
    }

    public function getGames()
    {
        //..
    }
}

Model:

class Model
{
    protected $db;
    protected $json;

    public function __construct(League\Container\Container $container)
    {
        $this->json = $container->get('json');
        $this->db = $container->get('database');
    }
}
class ApiModel extends Model
{
    /**
     * Get games
     * @return mixed
     */
    public function getGames()
    {
        //db queries etc...
    }
}

Something saying me, that this is not right way.

I'm currently using an asp datasource to bind my navigation menu but I'm having a hard time tieing it to my security criteria which is a String method in behind code.

My asp datasource looks like this

<data:ViewUserPageNavigationDataSource ID="navMenuData" runat="server" SelectMethod="GetPaged">
            <Parameters>
                <asp:ControlParameter Name="WhereClause" ControlID="__Page" PropertyName="ViewUserPageNavigationWhereClause" />
                <asp:ControlParameter Name="OrderBy" ControlID="__Page" PropertyName="ViewUserPageNavigationOrderBy" />
            </Parameters>
        </data:ViewUserPageNavigationDataSource>

Since i'm using __Page it's looking for my datasource on the child page. How do I point it to the masterpage?

DataBinding: 'ASP.secure_index_aspx' does not contain a property with the name 'ViewUserPageNavigationWhereClause'.

Thanks!

I want to make just the simplest possible POST, so that if I make a POST I can then get a return status of success, what's the simplest possible trivial case for this problem?

I am not able to load the gridview on page load. It keeps giving me

Uncaught TypeError: Cannot read property 'length' of undefined. I have mnetioned the code and the handler beneath. Please help me solve the issue. The issue happens in the Jquery.

 <script type="text/javascript">
             $(document).ready(function () {
                 BindGridView();

             });


 function BindGridView() {
             $.ajax({
                 type: "POST",
                 url: "../Pm/uc/G.ashx/GetMailDetail",
                 contentType: "application/json;charset=utf-8",
                 data: {},
                 dataType: "json",
                 success: function (data) {
                     if (data.d.length > 0) {
                         $("#grdDemo").append("<tr><th>Username</th></tr>");
                         for (var i = 0; i < data.d.length; i++) {

                             $("#grdDemo").append("<tr><td>" + 
                             data.d[i].Username + "</td> <td>");
                         }
                     }
                 },
                 error: function (result) {
                 }
             });
         }
        </script>

     <asp:GridView ID="grdDemo" runat="server">
        </asp:GridView>

This is in the Handler.( You can replace the query with anything.)

 public void ProcessRequest(HttpContext context)
    {
        //int mailid = int.Parse(context.Request["mid"]);
        //var detail = GetMailDetail(mailid);
        var detail = GetMailDetail();

        if (detail != null)
        {
            context.Response.ContentType = "application/json";
            string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(detail);
            context.Response.Write(json);
        }
        else
        {
            context.Response.StatusCode = 404;
        }
    }

    //protected object GetMailDetail(int mailid)
    protected object GetMailDetail()
    {
        List<DetailsClass> Detail = new List<DetailsClass>();

        Connection Con = new Connection();
        String Connection = Con.Active_Connection();
        SqlConnection con = new SqlConnection(Connection);
        con.Open();
        DataTable dt = new DataTable();

        SqlCommand cmd = new SqlCommand("select Sp4_Txt from  Sp4", con);

        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dtGetData = new DataTable();

        da.Fill(dtGetData);

        foreach (DataRow dtRow in dtGetData.Rows)
        {
            DetailsClass DataObj = new DetailsClass();
            DataObj.Username = dtRow["Sp4_Txt"].ToString();
            Detail.Add(DataObj);
        }

        return Detail.ToArray();
    }
    public class DetailsClass //Class for binding data
    {
        public string Username { get; set; }
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

When i enter the Permanent Address then i click checkbox the value of Permanent Address will be displayed in the Temporary Address field But sate field is not bind in the Temporary Address field

<h5 class="with-border">Permanent Address </h5>
                                    <div class="row">
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Address line 1</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.PAddress1, new { @class = "form-control", @id = "txtPPAddress1", placeholder = "Address Line1" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Address Line2</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.PAddress2, new { @class = "form-control", @id = "txtPPAddress2", placeholder = "Address Line2" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Country</label>
                                                @Html.DropDownList("CountryNew", null, "--- Select Country ---", new { @class = "select2-arrow" })
                                            </fieldset>
                                        </div>
                                    </div><!--.row-->
                                    <br />
                                    <div class="row">
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">State</label>
                                                <select id="stateNew" class="select2-arrow"></select>
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">City</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.PCity, new { @class = "form-control", @id = "txtPPCity", placeholder = "City" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Pincode</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.PPinCode, new { @class = "form-control", @id = "txtPPPinCode", placeholder = "Pincode" })
                                            </fieldset>
                                        </div>
                                    </div><!--.row-->
                                    <br />
                                    <div class="row">
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Land Mark</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.PLandMark, new { @class = "form-control", @id = "txtPPLandMark", placeholder = "Land Mark" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Phone No</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.PPhoneNo, new { @class = "form-control", @id = "txtPPPhoneNo", placeholder = "Phone Number" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Mobile Number</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.PMobileNo, new { @class = "form-control", @id = "txtPPMobileNo", placeholder = "Mobile Number" })
                                            </fieldset>
                                        </div>
                                    </div><!--.row-->
                                    <br />
                                    <br />
                                    <div class="checkbox">
                                        <input type="checkbox" id="check-1">
                                        <label for="check-1">Billing Address is same as Shipping Address.</label>
                                    </div>
                                    <br />
                                    <br />
                                    <h5 class="with-border">Temporary Address </h5>
                                    <div class="row">
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Address line 1</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.TAddress1, new { @class = "form-control", @id = "txtTAddress1", placeholder = "Address Line1" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Address Line2</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.TAddress2, new { @class = "form-control", @id = "txtTAddress2", placeholder = "Address Line2" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Country</label>
                                                @Html.DropDownList("CountryNew1", null, "--- Select Country ---", new { @class = "select2-arrow" })
                                            </fieldset>
                                        </div>
                                    </div><!--.row-->
                                    <br />
                                    <div class="row">
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">State</label>
                                                <select id="stateNew1" class="select2-arrow"></select>
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">City</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.TCity, new { @class = "form-control", @id = "txtTCity", placeholder = "City" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Pincode</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.TPinCode, new { @class = "form-control", @id = "txtTPinCode", placeholder = "Pincode" })
                                            </fieldset>
                                        </div>
                                    </div><!--.row-->
                                    <br />
                                    <div class="row">
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Land Mark</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.TLandMark, new { @class = "form-control", @id = "txtTLandMark", placeholder = "Land Mark" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Phone No</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.TPhoneNo, new { @class = "form-control", @id = "txtTPhoneNo", placeholder = "Phone Number" })
                                            </fieldset>
                                        </div>
                                        <div class="col-lg-4">
                                            <fieldset class="form-group">
                                                <label class="form-label semibold control-label">Mobile Number</label>
                                                @Html.TextBoxFor(model => model.pharmaCompanyDivision.TMobileNo, new { @class = "form-control", @id = "txtTMobileNo", placeholder = "Mobile Number" })
                                            </fieldset>
                                        </div>
                                    </div><!--.row-->

Script:

$(document).ready(function () {
        $('input:checkbox[id*=check-1]').change(function () {

            if ($(this).is(':checked')) {
                $('input:text[id*=txtTAddress1]').val($('input:text[id*=txtPPAddress1]').val());
                $('input:text[id*=txtTAddress2]').val($('input:text[id*=txtPPAddress2]').val()); 
                $('select[id*=CountryNew1]').val($('select[id*=CountryNew]').val()); 
                $('select[id*=stateNew1]').val($('select[id*=stateNew]').val()); 
                $('input:text[id*=txtTCity]').val($('input:text[id*=txtPPCity]').val()); 
                $('input:text[id*=txtTPinCode]').val($('input:text[id*=txtPPPinCode]').val()); 
                $('input:text[id*=txtTLandMark]').val($('input:text[id*=txtPPLandMark]').val());
                $('input:text[id*=txtTPhoneNo]').val($('input:text[id*=txtPPPhoneNo]').val());
                $('input:text[id*=txtTMobileNo]').val($('input:text[id*=txtPPMobileNo]').val());
            }
            else {
                $('input:text[id*=txtTAddress1]').val('');
                $('input:text[id*=txtTAddress2]').val('');
                $('select[id*=CountryNew1]').val('');
                $('select[id*=stateNew1]').val('');
                $('select[id*=txtTCity]').val('');
                $('select[id*=txtTPinCode]').val('');
                $('select[id*=txtTLandMark]').val('');
                $('select[id*=txtTPhoneNo]').val('');
                $('select[id*=txtTMobileNo]').val('');
            }
        });
    });

ImageNot Pass

State bind code Example:

$("#CountryNew").change(function () {
                    var id = $(this).val();
                    $("#stateNew").empty();
                    $.get("State_BindNew", { CountryID: id }, function (data) {
                        var v = "<option>--- Select State ---</option>";
                        $.each(data, function (i, v1) {
                            v += "<option value=" + v1.Value + ">" + v1.Text + "</option>";
                        });
                        $("#stateNew").html(v);
                    });
            });

            $("#CountryNew1").change(function () {
                var id = $(this).val();
                $("#stateNew1").empty();
                $.get("State_BindNew1", { CountryID: id }, function (data) {
                    var v = "<option>--- Select State ---</option>";
                    $.each(data, function (i, v1) {
                        v += "<option value=" + v1.Value + ">" + v1.Text + "</option>";
                    });
                    $("#stateNew1").html(v);
                });
            });

After apply bootstrap asp.net textbox shows text like this. How to solve this issue? I applied line-height:0. But no effect.this is the issue

I'm a total newbie into Angular/Typescript web development.

I'm developing a website using ASP.NET Core 2.0 and Angular 4. It needs to fetch some data and present it at the homepage (that would be the home component of the Angular app). I've seen some examples and they suggest doing something like this:

import { Component, Inject } from '@angular/core';
import { Http } from '@angular/http';
@Component({
    selector: 'quotes',
    templateUrl: './quotes.component.html'
})
export class FetchDataComponent {
    public quotes: Quote[];

    constructor(http: Http, @Inject('BASE_URL') baseUrl: string) {
        http.get(baseUrl + 'api/quotes/recent').subscribe(result => {
            this.quotes = result.json() as Quote[];
        }, error => console.error(error));
    }
}

interface Quote {
    text: string;
    author: string;
    timeStamp: Date;
}

That code works fine when the component is not the first one to be presented when the page is loaded. If I try to fetch data on the home component, the server freaks out and throws all kind of exceptions. First, it throws a TaskCancelledException, and further requests throw:

NodeInvocationException: Prerendering timed out after 30000ms because the boot function in 'ClientApp/dist/main-server' returned a promise that did not resolve or reject.

I'm assuming that I'm doing stuff very wrong, but I haven't seen any other way of doing what I want.

I tried moving the offending code (the http.get request) to a separate function, but now I don't know how am I supposed to call it when the component finished loading.

import { Component, Inject } from '@angular/core';
import { Http } from '@angular/http';
@Component({
    selector: 'quotes',
    templateUrl: './quotes.component.html'
})
export class FetchDataComponent {
    public quotes: Quote[];
    private ht: Http;
    private url: string;

    constructor(http: Http, @Inject('BASE_URL') baseUrl: string) {
        this.ht = http;
        this.url = baseUrl;
    }

    fetchQuotes(): void {
        this.ht.get(baseUrl + 'api/quotes/recent').subscribe(result => {
            this.quotes = result.json() as Quote[];
        }, error => console.error(error));
    }
}

interface Quote {
    text: string;
    author: string;
    timeStamp: Date;
}

No http event has helped me. I can make everything work using the (click)="" directive, but obviously, I don't want the user to have to click something for the app to work as expected. No other directive seems to work either.

Below is the code I have on the html of the component:

<p class="warning" *ngIf="!quotes" (click)="fetchQuotes()">
    <span class="glyphicon glyphicon-warning-sign"></span>
    <em>There's nothing to show yet.</em>
</p>
<div *ngIf="quotes">
    <ul class="quoteList" *ngFor="let quote of quotes">
        <li>
            {{ quote.text }}
            <small>{{ quote.author }}, {{ quote.timeStamp }}</small>
        </li>
    </ul>
</div>

So to summarize, I need a way to fetch data for the component that Angular will show by default upon loading the page.

I'm working on a assignment. And stuck in downloading section. I can upload the file. But when i'm trying to download the same file after uploading i get error (Access is Denied). Here is the code which i have written.

[HttpGet]

    public FileResult Download (string fileName)
    {
        var permissionSet = new PermissionSet(PermissionState.None);
        var writePermission = new FileIOPermission(FileIOPermissionAccess.Write, @"D:\Assignment\Ment\Ment\Photos");
        permissionSet.AddPermission(writePermission);
        var FileVirtualPath = Server.MapPath("~/Photos/" + fileName); //"~/Photos/" + fileName;
        return new FilePathResult(@"D:\Assignment\Ment\Ment\Photos", "application/octet-stream");

    }

I would like to keep the server running (alive) all the day (at least to the midnight when it can be recycled by scheduling) so I've found that setting Start Mode to AlwaysRunning can help achieve this. But still there is another option which seems to confict with that AlwaysRunning, that is Idle Timeout Action. The Idle Timeout is still kept at the default value of 20 minutes, but the Idle Timeout Action is set to Terminate. So I'm not really sure if which setting takes over the other? In this case I think the Start Mode should override the Idle Timeout Action.

Thanks for your help!

I have

public class ClassA
{
    public int ID { get; set; }
    public List<ClassB> ClassBList { get; set; }
}


public class ClassB
{
    public int ID { get; set; }
    public string Name { get; set; }
    public bool IsValid { get; set; }
}

In my ViewModel I have a List of ClassA. In my view, I want the put the list of ClassA's in a form as well as their containing ClassB's so that both the ClassA and ClassB objects can be updated.

So in my view I have

@for (int i = 0; i < Model.ClassA.Count(); i++)
{
    <input asp-for="@Model.ClassA[i].ID" />

    @for (int j = 0; i < Model.ClassA[i].ClassBList.Count(); j++)
    {
       <input asp-for="@Model.ClassA[i].ClassBList[j].ID" />
       <input asp-for="@Model.ClassA[i].ClassBList[j].Name" />
       <input asp-for="@Model.ClassA[i].ClassBList[j].IsValid" />
    }
}

When the form submits, in the post method, the ClassA properties get updated, however, none of the ClassB properties for that ClassA object do.

Is there a way to engage the properties in ClassBList as well as its parent ClassA properties?

I'm displaying my enum list in a select box, they show the display name ex "Andorra". But in the value of each select element I want to see the country code ex. US, GA, UM, VC, etc But my values is showing as a number like 1,2,3,4,5.

How can I get the country code 'US, GA, etc' instead of the numbered value?

@Html.EnumDropDownListFor(m => m.Countries, null, new { @id = "Country", @class = "form-control selectpicker" })

Here is my enum

public enum CountryCode
{

    ///<sumary>
    /// Andorra
    ///</sumary>
    [Display(Name = "Andorra")]
    AD,
    ///<sumary>
    /// United Arab Emirates
    ///</sumary>
    [Display(Name = "United Arab Emirates")]
    AE,
    ///<sumary>
    /// Afghanistan
    ///</sumary>
    [Display(Name = "Afghanistan")]
    AF
}

I am using an EditorTemplate for localized displaying a DateTimeOffset.

EditorTemplate:

@model DateTimeOffset?
@Html.TextBox("", (Model.HasValue ? Model.Value.ToLocalTime()
    .ToString("yyyy-MM-dd HH:mm") : string.Empty), new
    {
        @class = "form-control datetimepicker"
    })

This is working correctly when I am using the Html.EditorFor. However, I would like to pass additional htmlAttributes to the object in my view.

View:

@Html.EditorFor(model => model.ValidToDate, new { 
    htmlAttributes = new { @data_date_min_date = DateTime.Now.ToString() } 
})

The attribute in this example (data_date_min_date) doesn't get rendered. How can I provide additional htmlAttributes to a field that are specific for a certain view?

I am trying to create a small asmx service with a method which will return some dummy data. I get the following error when I run the service: "System.InvalidOperationException: System.Xml.XmlAttribute cannot be used as: 'xml element'."

My web method is as follows:

[WebMethod]
public SubmitCaseRequestResponse1 SubmitCaseRequest(SubmitCaseRequestRequest1 request)
{

    var response = new SubmitCaseRequestResponse1
    {
        ResponseID = "456325898",
        Success = true,
        ValidationErrors = null

    };
    return response;
}

My SubmitCaseRequestResponse1 class:

public class SubmitCaseRequestResponse1

{ public string ResponseId { get; set; }

public bool Success { get; set; }

public ValidationError[] ValidationErrors { get; set; }

}

and the request class is :

public class SubmitCaseRequestRequest1

{ public AuthHeader AuthHeader { get; set; }

public SubmitCaseRequestRequest PostCaseDateRequest { get; set; }

}

I am developing a web app using ASP.NET MVC 5. I have multiple partial views and their corresponding models, but only one controller corresponding to the main view, that uses below code to display each of the partial views.

@{Html.RenderPartial("PartialViewName");} 

My question is, how do I pass the form data from all the partial views (including the main view) to the main controller?

Initially, when I added only 1 partial view, I added it's model as a parameter to the main controller's public ActionResult Index(MainModelName model1, PartialModelName pmodel1). and that worked fine and I could access the data from the partial view in the main controller.

But, when I added the 2nd partial view and updated the public ActionResult Index(...) with an additional partial model parameter, it didn't help, as in the data is not being passed from the partial view to the main controller. though I don't get any error.

My main model class has the object references of the partial models as its data members. From what I read, I need to have a list of models as a parameter to the method in the main controller, but my models are not sub-types.

What's the idiomatic way of handling such a situation?

Thank you!

I set up the cookie in the Startup.Auth as below

app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Account/Login"),
        ExpireTimeSpan = TimeSpan.FromDays(14),
        SlidingExpiration = true,
        CookieName = "MyCookie",
        CookieDomain = ".domain.com",

        Provider = new CookieAuthenticationProvider
        {
            // Enables the application to validate the security stamp when the user logs in.
            // This is a security feature which is used when you change a password or add an external login to your account.  
            OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                validateInterval: TimeSpan.FromMinutes(30),
                regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))

        }
    });   

However when the cookie is created, the above options are completely ignored. I specify the cookie the same way in another application and it works fine. Why are my cookie settings being ignored? Is there somewhere else in the project that the cookie options could be specified?

How to add .aspx page to MVC 4 solution and consume web api from code behind to pull data