I'm seeing an issue where my application is throwing an exception reading as follows:

Exception information: Exception type: PlatformNotSupportedException Exception message: This operation requires IIS integrated pipeline mode. at System.Web.HttpRequest.Abort() at System.Web.HttpRequestWrapper.Abort() at System.Web.Http.WebHost.HttpControllerHandler. d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotifica>tion(Task task) at System.Web.Http.WebHost.HttpControllerHandler.d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.WebHost.HttpControllerHandler.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpTaskAsyncHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Setting the pipeline to Integrated mode isn't an option because of a large amount of legacy code that depends on Classic mode. Most of the errors I've seen have been related to setting response headers, but I'm not doing that here. The entry in the Event Viewer is showing the request URL, and here's the controller method that is being executed at that path:

[ApiAuthorize]
    [HttpPost, Queryable(AllowedQueryOptions = AllowedQueryOptions.All, PageSize = 25)]
    public IQueryable<usp_Collections_GetCustomersWithActionsForUser_Result> GetCustomersWithActionsDue([FromODataUri] int key)
    {
        //TODO: Add handling to return 404 or other status code if no records are returned
        //      Also add general try catch
        var customersWithActionsDue = ClientData.usp_Collections_GetCustomersWithActionsForUser(key, 1).AsQueryable();

        return customersWithActionsDue;
    }

The application returns a response correctly, formatted as JSON, the exception is only being logged in the event viewer and isn't stopping the request from processing. It's also a little hard to reproduce since I'm unable to do so locally, I suspect it's something in the configuration of the remote web server. Anyone have any ideas what might be causing it? Any help would be greatly appreciated. Thanks!

I have a DataGrid that I am trying to export when an ASP.NET Button is clicked.

error screen

The exact error is:

Control 'ctl00_body_RollupDG_ctl02_btnShowGLdetail' of type 'LinkButton' must be placed inside a form tag with runat=server.

I found similar questions on here, but all seem to indicate that this comes from the ASP.NET control NOT being placed within a ContentPlaceHolder or a ContentPlaceHolder NOT being placed within a RunAt Server form.

I have both of these, so that is not the case here.

My ExportExcelFile method catches the HttpException at RenderControl() (as shown in the screenshot above). That code is as follows:

protected void ExportExcelFile(object Sender, EventArgs e) { //export to excel
    var grdResults = (periodCriteria.SelectedValue == "year") ? RollupDG : QuarterDG;
    var response = HttpContext.Current.Response;
    response.Clear();
    response.Charset = String.Empty;
    response.ContentType = "application/vnd.ms-excel";
    response.AddHeader("Content-Disposition", "attachment; filename=GlBudgetReport.xls");
    using (var sw = new StringWriter()) {
        using (var htw = new HtmlTextWriter(sw)) {
            grdResults.RenderControl(htw);
            response.Write(sw.ToString());
            response.End();
        }
    }
}

As shown in my Find Results box below, there are several ASP.NET LinkButton controls, but each of them does contain the runat="server" clause.

Find Results

It appears the LinkButton data in the DataGrid has difficulty rendering as Plain Text.

If not, is there something in my export method that can be configured so that the DataGrid data is all interpreted as text?

I could create a blank DataGrid, then walk through the filled DataGrid, writing in only the text of each field - but I only want to do this if it is absolutely necessary.

I am an active directory user and I am simply trying to print the name of the current user out in a Respnse.Write() method. From what I read from several other questions posted here I need to use

using System.Security.Principal;
string username = WindowsIdentity.GetCurrent().Name

However, when I try to write the username to the screen I get

NT AUTHORITY\NETWORK SERVICE

instead of

domain\12345678

Here is the code I am using to write to the screen:

Response.Write(WindowsIdentity.GetCurrent().Name);

and I have identity impersonate set to true in my web.config. What do I do next?

This question already has an answer here:

The audit department does not want the programmers to have access to the production sql account for the web apps.

Right now the programmers know the username and password and its being entered in the web.config.

Is there a way where the web.config can be configured to allow the programmers to do their job? Once the web app is moved to production its using different credentials where the programmers dont know the password.

Any help would be appreciated.

Thanks

i will be starting the new project for meeting room management which it will include reporting and catering. this project is for company with 3 office different part of the city and 500 users and i will be working on it alone.
Before i can decide to use the MVC or Web From, would like to know what are the pros and cons of each way, And which version of MVC is best option and Why?"

This is related my question which i asked in this link correct me on url routing in mvc

Now i came with another problem, so i thought i will ask it as new question.

Now i have following routes in my global.asax file

routes.MapRoute(
           "Custom", // Route name
           "{action}/{id}", // URL with parameters
           new { controller = "Authentication", action = "BigClientLogin", id = UrlParameter.Optional } // Parameter defaults
       );

and

routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Authentication", action = "BigClientLogin", id = UrlParameter.Optional } // Parameter defaults
        );

Now what happens is when i run my solution the URL i am getting is http://localhost:65423/Login this is what i need for my Login Page that is OK. But when i login in as user i am getting "The resource cannot be found" error.

when i checked it i can see that my URL is now changed to "http://localhost:65423/Admin/Dashboard"

So i think this causing the issue. So this looks the problem related to my global.asax routing.

Can anyone help me to find out what i did wrong.

I am currently developing a web application and I want to show the current logged in users details. When the users logs in I have created a new session and I am trying to use this to validate the current user and display their details. The C# code is shown below.

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            conn.Open();
            string detailsQuery = "select * FROM [Customer] where Customer_No ='" + Session["New"] + "'";
            SqlCommand com = new SqlCommand(detailsQuery, conn);
            com.ExecuteNonQuery();                
            Response.Write("Details Showing");
            conn.Close();
        }
        catch (Exception ex)
        {
            Response.Write("Error:" + ex.ToString());
        }
    }

I can easily show all the customers details but I can't figure out how to show the current logged in user. I would be grateful for any help.

I have a gridview which is binded to a datasource like this:

var beerlist = (from b in ctx.beers
select new
                        {
                            id = b.beerid,
                            b.brand,
                            b.kind,
                            etc...       }).ToList();
        BeerListGridView.DataSource = beerlist;
        DataBind();

i do this in the page_load event with: if (!IsPostBack).

now i add buttons in the onrowdatabound event like this:

if (e.Row.RowType == DataControlRowType.DataRow)
    {
        String beerid = e.Row.Cells[0].Text;
        int columncount = e.Row.Cells.Count;

        TableCell MyCell = new TableCell();
        Button EditButton = new Button();
        EditButton.ID = beerid;
        EditButton.Text = "Edit";
        EditButton.CommandName = "EditButton_Click";
        EditButton.CommandArgument = beerid;
        MyCell.Controls.Add(EditButton);
        MyCell2.Controls.Add(InfoButton);
        e.Row.Cells.AddAt(columncount, MyCell);
        e.Row.Cells.AddAt(columncount + 1, MyCell2);

the rowcommand event looks like this:

if (e.CommandName != "Sort")
    {
        Session["beerid"] = e.CommandArgument;
        if (e.CommandName == "EditButton_Click")
        {
            Response.Redirect("EditBeer.aspx");
        }
        else if (e.CommandName == "InfoButton_Click")
        {
            Response.Redirect("ViewRatingsRemarks.aspx");
        }
    }

in the sorting event i do the following:

if (e.SortExpression == "brand")
    {
        if (Session["brandsortorder"] == null)
        {
            var beerlist = (from b in ctx.beers
                            orderby b.brand
                            select new
                            {
                                id = b.beerid,
                                b.brand,
                                b.kind,
                                etc...          }).ToList();
            BeerListGridView.DataSource = beerlist;
            DataBind();
            Session["brandsortorder"] = "DESC";
        }
        else if  etc..

when i click the edit button al the buttons disappear an i am left with the datagridview without the buttons. What am i doing wrong?

Is there anyone who has managed to make an application that perform a login action and keep the session of a user from a DocumentDB in asp.net mvc 5. I tried, but I didn't. I created a model MyUser.cs

public class MyUser
  {

    [JsonProperty(PropertyName = "id")]
    public string id { get; set; }

    [JsonProperty(PropertyName = "mail")]
    public string mail { get; set; }

    [JsonProperty(PropertyName = "password")]
    public string password { get; set; }
  }

A controller MyUserController

public class MyUserController : Controller
  {
    public ActionResult Index()
    {
      var client = DocumentDBRepository.InstantiatesClient();
      var database = DocumentDBRepository.ReadOrCreateDatabase("myDB");
      var collection = DocumentDBRepository.ReadOrCreateCollection(database.SelfLink, "myUsers");
      List<Server_MVC5.Models.MyUser> users = DocumentDBRepository.getMyUsers(collection);
      return View(users);
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public async Task<ActionResult> Login([Bind(Include = "email,password")] Models.MyUser myuser)
    {
      if (ModelState.IsValid)
      {
        DocumentDBRepository.Login(myuser.mail, myuser.password);
        return RedirectToAction("Index");
      }

      return View(myuser);
    }

    public ActionResult Login(string email, string password)
    {
      if (email == null)
      {
        return HttpNotFound();
      }

      Models.MyUser myuser = DocumentDBRepository.Login(email, password);
      if (myuser == null)
      {
        return HttpNotFound();
      }

      return View("Index");
    }
  }

A view for login Login.cshtml

@using Server_MVC5.Models
@model LoginViewModel
@{
    ViewBag.Title = "Log in";
}

<h2>@ViewBag.Title.</h2>
<div class="row">
    <div class="col-md-8">
        <section id="loginForm">
            @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
            {
                @Html.AntiForgeryToken()
                <h4>Use a local account to log in.</h4>
                <hr />
                @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                <div class="form-group">
                    @Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
                    <div class="col-md-10">
                        @Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
                    <div class="col-md-10">
                        @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <div class="checkbox">
                            @Html.CheckBoxFor(m => m.RememberMe)
                            @Html.LabelFor(m => m.RememberMe)
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" value="Log in" class="btn btn-default" />
                    </div>
                </div>
                <p>
                    @Html.ActionLink("Register as a new user", "Register")
                </p>
                @* Enable this once you have account confirmation enabled for password reset functionality
                    <p>
                        @Html.ActionLink("Forgot your password?", "ForgotPassword")
                    </p>*@
            }
        </section>
    </div>
    <div class="col-md-4">
        <section id="socialLoginForm">
            @Html.Partial("_ExternalLoginsListPartial", new ExternalLoginListViewModel { ReturnUrl = ViewBag.ReturnUrl })
        </section>
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

I state that DocumentDBRepository is a repo that retrieve info from my DocumentDB Azure Db (it works properly). When I perform login, it returns ever failure despite the credentials are correct. Does anyone know how to help me ?

How can i implement simple DropDownList without Id.

public AddItemModel() 
{
    Types = new SelectList(new []{"Type1", "Type2", "Type3"});
}

public SelectList Types { get; set; }

@Html.DropDownListFor(x => x.AddItem, ???

I want to provide a simple general functionality to show a message at the top of a page whenever I need to inform a user that operation is successful. My solution would be to put an object into ViewBag.Info that contains details about a message, including bool public IsMessage;and read it in _Layout.cshtml where I have an extra hidden div.

The way I am trying to do it in _Layout.cshtml is I put what's in @(ViewBag.Info.IsMessage (false/true) into a hidden field and read it by JavaScript. If the field contains "true", javascript will invoke a function ShowEvent().

For some reason, if I add the line @(ViewBag.Info.IsMessage.ToString().ToLower()) VS2010 complains about ViewBag.Title in _Layout.cshtml.

"Cannot perform runtime binding on a null reference"

The code of _Layout.cshtml is simple:

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link rel="Stylesheet" type="text/css" href="@Url.Content("~/Content/StyleSheet.css")" />
    <script src="~/Scripts/jquery-2.1.1.min.js" type="text/javascript"></script>
    <title>@ViewBag.Title</title>
</head>
<body>
    <input type="hidden" id="is-event" name="is-event" value="@(ViewBag.Info.IsMessage.ToString().ToLower())"/>
    <div class="recent-events"></div>
    <div>
        @if (IsSectionDefined("loginfo"))
        {
            @RenderSection("loginfo", false)
        }
        @RenderBody()
        @if (IsSectionDefined("Home"))
        {
            @RenderSection("Home", false)
        }
    </div>
</body>
</html>

And the code of the View Index.cshtml is:

@model TestProject.ViewModels.Account.UserData
@{
    ViewBag.Title = "Index";
    string identityName = HttpContext.Current.User.Identity.Name;
    string userrole = Model.UserRoles.FirstOrDefault();
}

<h2>Index</h2>
<br />

As you can see ViewBag.Title is defined.

EDIT. The code of the controller:

public ActionResult Index()
{
    // ...
    InfoModel infoModel = new InfoModel()
    {
        IsMessage = true, Duration = 3000, Message = "Logging in successfull", BackgroundColor = "#bbffbb"
    };
    ViewBag.Info = infoModel;
    ViewBag.Title = string.Empty;
    return View(userdata);
}

i am trying to show the Layout page content in normal razor view but it is not working. in plain html page it's working fine. enter image description here

But if i want to implement this in asp.net mvc then the Layout page content is not showing enter image description here

i am not sure where i am getting wrong.

This is my plain html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Focus / Seçkin Bütün</title>


    <link href="Asset/Style/Bootstrap.css"               rel="stylesheet" />
    <link href="Asset/Style/Bootstrap-Theme.css"         rel="stylesheet" />
        <link href="Asset/Font/FontAwesome.css"              rel="stylesheet" />
    <link href="Asset/Style/Style.css"                   rel="stylesheet" />
    <link href="Asset/Style/Style-Responsive.css"        rel="stylesheet" />
    <link href="Asset/Style/Print.css"                   rel="stylesheet" media="print" />
    <link href="Favicon.ico"                             rel="shortcut icon" />
    <script src="Asset/Script/jQuery.js"                type="text/javascript"></script>
    <script src="Asset/Script/Angular.js"               type="text/javascript"></script>
    <script src="Asset/Script/Bootstrap.js"             type="text/javascript"></script>
      <script src="Asset/Script/Spin.js"                  type="text/javascript"></script>
    <script src="Asset/Script/Design.js"                type="text/javascript"></script>
    <script src="Asset/Script/Script.js"                type="text/javascript"></script>

</head>
<body>
    <span id="ToastBox"></span>
    <section id="container">
        <header class="navbar navbar-default navbar-static-top clearfix Header" id="Header" role="navigation">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a class="navbar-brand" href="#"><img src="Asset/Image/Logo_Focus.png" alt=""></a>
                </div>
                <div class="navbar-collapse collapse">

                    <ul class="nav navbar-nav NavMenuSide">
                        <li><a class="fa fa-bars ButtonCircle" id="btnSideMenu" href="javascript:;"></a></li>
                    </ul>

                    <ul class="nav navbar-nav navbar-right NavMenuRest">
                        <li class="dropdown NavSubMenuUser">
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"><span class="caret"></span> Seçkin Bütün</a>
                            <ul class="dropdown-menu" role="menu">
                                <li><a href="#"><i class="fa fa-bell-o"></i> Notifications</a></li>
                                <li><a href="#"><i class="fa fa-cog"></i> Profile</a></li>
                                <li><a href="#"><i class="fa fa-key"></i> Logout</a></li>
                            </ul>
                        </li>
                        <li class="dropdown NavSubMenuNotification">
                            <a href="javascript:;" class="dropdown-toggle fa fa-bell-o ButtonCircle NavSubMenuNotification" data-toggle="dropdown" id="btnNotification"></a>
                            <ul class="dropdown-menu" role="menu">
                                <li><a href="#">• Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed et lorem lectus. Vestibulum vel felis enim. Nullam egestas justo at nunc semper</a></li>
                                                         </ul>
                        </li>
                        <li class="NavSubMenuLock"><a class="fa fa-lock ButtonCircle" id="btnLock" href="#"></a></li>
                    </ul>
                </div>
            </div>
        </header>

        <aside id="SideMenu" class="SideMenu">

                <div class="SideNavigation">
                    <ul class="Side-Accordion" id="Side-Accordion">

                        <li><a href="#"><i class="fa fa-dashboard"></i><span>Dashboard</span></a></li>
                        <li class="Sub-Accordion">
                            <a href="javascript:;"><i class="fa fa-tasks"></i><span>Operation</span></a>
                            <ul class="Sub-AccordionList Active">
                                <li><a href="#">Cost</a></li>
                                <li><a href="#">Customer</a></li>
                                                          </ul>
                        </li>
                        <li class="Sub-Accordion">
                            <a href="javascript:;"><i class="fa fa-building-o"></i><span>Definition</span></a>
                            <ul class="Sub-AccordionList">
                                <li><a href="#">Brand</a></li>

                            </ul>
                        </li>
                        <li class="Sub-Accordion">
                            <a href="javascript:;"><i class="fa fa-bar-chart-o"></i><span>Report</span></a>
                            <ul class="Sub-AccordionList">
                                <li><a href="#">Factory</a></li>
                                                            </ul>
                        </li>
                        <li class="Sub-Accordion">
                            <a href="javascript:;"><i class="fa fa-gears"></i><span>Administration</span></a>
                            <ul class="Sub-AccordionList">
                                <li><a href="#">Configuration</a></li>
                                                           </ul>
                        </li>

                    </ul>
                </div>
        </aside>
        <section class="container-fluid MainContent">

            <div class="row">
                <div class="col-sm-12">

                    <div class="page-header FocusHeader">
                        <h1>Profile</h1>
                    </div>
                </div>
            </div>
        </section>
    </section>
    <script src="Asset/Script/Complete.js" type="text/javascript"></script>
</body>
</html>

and this is my Layout page

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Focus / Seçkin Bütün</title>
    <meta name="author" content="Magnifo / http://www.magnifo.com" />

    @Scripts.Render("~/bundles/AssetScripts")

    <link rel="stylesheet" type="text/css" href="@Url.Content("~/Asset/Style/Bootstrap-Theme.css")" />
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/Asset/Style/Bootstrap.css")" />
         <link rel="stylesheet" type="text/css" href="@Url.Content("~/Asset/Style/Markup.css")" />
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/Asset/Style/Print.css")" />
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/Asset/Style/Style-Responsive.css")" />
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/Asset/Style/Style.css")" />
</head>
<body>
    <div>
        <span id="ToastBox"></span>
        <section id="container">
            <header class="navbar navbar-default navbar-static-top clearfix Header" id="Header" role="navigation">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <a class="navbar-brand" href="#"><img src="Asset/Image/Logo_Focus.png" alt=""></a>
                    </div>
                    <div class="navbar-collapse collapse">

                        <ul class="nav navbar-nav NavMenuSide">
                            <li><a class="fa fa-bars ButtonCircle" id="btnSideMenu" href="javascript:;"></a></li>
                        </ul>
                        <ul class="nav navbar-nav navbar-right NavMenuRest">
                            <li class="dropdown NavSubMenuUser">
                                <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"><span class="caret"></span> Seçkin Bütün</a>
                                <ul class="dropdown-menu" role="menu">
                                    <li><a href="#"><i class="fa fa-bell-o"></i> Notifications</a></li>
                                                                   </ul>
                            </li>
                            <li class="dropdown NavSubMenuNotification">
                                <a href="javascript:;" class="dropdown-toggle fa fa-bell-o ButtonCircle NavSubMenuNotification" data-toggle="dropdown" id="btnNotification"></a>
                                <ul class="dropdown-menu" role="menu">
                                    <li><a href="#">• Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed et lorem lectus. Vestibulum vel felis enim. Nullam egestas justo at nunc semper</a></li>
                                                                 </ul>
                            </li>
                            <li class="NavSubMenuLock"><a class="fa fa-lock ButtonCircle" id="btnLock" href="#"></a></li>
                        </ul>
                    </div>
                </div>
            </header>
            <aside id="SideMenu" class="SideMenu">
                <div class="SideNavigation">
                    <ul class="Side-Accordion" id="Side-Accordion">

                        <li><a href="#"><i class="fa fa-dashboard"></i><span>Dashboard</span></a></li>
                        <li class="Sub-Accordion">
                            <a href="javascript:;"><i class="fa fa-tasks"></i><span>Operation</span></a>
                            <ul class="Sub-AccordionList Active">
                                <li><a href="#">Cost</a></li>
                                                         </ul>
                        </li>
                        <li class="Sub-Accordion">
                            <a href="javascript:;"><i class="fa fa-building-o"></i><span>Definition</span></a>
                            <ul class="Sub-AccordionList">
                                <li><a href="#">Brand</a></li>

                            </ul>
                        </li>
                        <li class="Sub-Accordion">
                            <a href="javascript:;"><i class="fa fa-bar-chart-o"></i><span>Report</span></a>
                            <ul class="Sub-AccordionList">
                                <li><a href="#">Factory</a></li>

                            </ul>
                        </li>
                        <li class="Sub-Accordion">
                            <a href="javascript:;"><i class="fa fa-gears"></i><span>Administration</span></a>
                            <ul class="Sub-AccordionList">
                                <li><a href="#">Configuration</a></li>
                                                           </ul>
                        </li>

                    </ul>
                </div>
            </aside>
            <section class="container-fluid MainContent">

                <div class="row">
                    <div class="col-sm-12">

                        @RenderSection("featured", required: false)
                        @RenderBody()
                    </div>
                </div>
            </section>


        </section>
    </div>
</body>
</html>

razor view page

@{

    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Test</h2>

trying to write MVC PartialView Async as:

public virtual async Task<ActionResult> EmployeeList(c c)
    {
        System.Threading.Thread.Sleep(5000);
        var pageIndex = (c.page ?? 1) - 1; //MembershipProvider expects a 0 for the first page
        var search = (c.search ?? "");
        var pageSize = 10;

        EmployeeRepository er = new EmployeeRepository();
        var contextEmpList = await er.GetListAsync(x => x.Name_Ar.Contains(search) || search == string.Empty, pageIndex * pageSize, pageSize);
        List<EmployeeModel> empList =  Mapper.Map<List<EmployeeModel>>(contextEmpList);

        int totalUserCount = contextEmpList.FirstOrDefault().TotalRecords;
        var usersAsIPagedList = new StaticPagedList<EmployeeModel>(empList, pageIndex + 1, pageSize, totalUserCount);

        return PartialView(MVC.HR.Employee.Views._EmployeeList, usersAsIPagedList);
    }

but i have the following error:

Error 42 'UTIT.WebUI.Areas.HR.Controllers.T4MVC_EmployeeController.EmployeeList(UTIT.WebUI.Areas.HR.Controllers.c)': return type must be 'System.Threading.Tasks.Task' to match overridden member 'UTIT.WebUI.Areas.HR.Controllers.EmployeeController.EmployeeList(UTIT.WebUI.Areas.HR.Controllers.c)' D:\UTIT New Project\UTIT.WebUI\HR.EmployeeController.generated.cs 156 53 UTIT.WebUI

Problem I am developing an application using Spring 4.1.1 and Tiles 3.0.5. I could able to create Layout. When I add the Image tag directly in the layout.jsp, I could able to see the Images/CSS etc, but when I add same Image tag in the different JSP which is added as "attribute" to the Layout, then none of the resources is working. "I can see error in console as org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/abc/%3Cc:url%20value=%22/resources/images/slides/trial.jpg%22%20/%3E] in DispatcherServlet with name "abc".

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
                    classpath:spring/applicationContext-resource.xml
                    /WEB-INF/spring/applicationContext-base.xml
                    /WEB-INF/spring/applicationContext-dao.xml
        </param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>abc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>abc</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  </web-app>

Application Context

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


    <beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" id="handlerMapping">
        <beans:property name="alwaysUseFullPath" value="true"/>
    </beans:bean>
    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />
    <resources mapping="/styles/**" location="/resources/css" />
    <resources mapping="/images/**" location="/resources/images"/>
    <resources mapping="/js/**" location="/resources/js"/>
    <resources mapping="/fonts/**" location="/resources/fonts"/>

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <beans:bean id="tilesConfigurer"
     class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
        <beans:property name="definitions">
            <beans:list>
                <beans:value>/WEB-INF/tiles-defs/templates.xml</beans:value>
            </beans:list>
        </beans:property>
    </beans:bean>

    <beans:bean id="viewResolver"
     class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" />
    </beans:bean>



    <context:component-scan base-package="com.online.abc" />



</beans:beans>

Tiles Definition

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
       "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>
    <definition name="baseLayout" template="/WEB-INF/views/layout/layout.jsp">
        <put-attribute name="title" value="abc" />
        <put-attribute name="header" value="/WEB-INF/views/layout/header.jsp" />
        <put-attribute name="navigation" value="/WEB-INF/views/layout/navigation.jsp" />
        <put-attribute name="slider" value="/WEB-INF/views/layout/slider.jsp"/>
        <put-attribute name="body" value="" />
        <put-attribute name="footer" value="/WEB-INF/views/layout/footer.jsp" />
    </definition>
    <definition extends="baseLayout" name="login">
        <put-attribute name="title" value="SivaLabs : Login" />
        <put-attribute name="navigation" value="" />
        <put-attribute name="body" value="/WEB-INF/views/login.jsp" />
    </definition>
    <definition extends="baseLayout" name="home">
          <put-attribute name="title" value="SivaLabs : Welcome" />
          <put-attribute name="body" value="/WEB-INF/views/home.jsp" />
    </definition>
</tiles-definitions>

Layout.jsp

<!DOCTYPE html>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<html lang="en">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title><tiles:insertAttribute name="title" ignore="true" /></title>
        <link rel="stylesheet" type="text/css" href='<c:url value="/resources/css/styles.css" />' />
        <script src='<c:url value="/resources/js/jquery/jquery-2.1.3.min.js" />'> </script>
        <script src='<c:url value="/resources/js/unslider/unslider.js" />'> </script>
    </head>
    <body class="body">
        <div class="headerContent">
            <header class="mainHeader">
                    <tiles:insertAttribute name="header" />
            </header>
        </div>

                    <tiles:insertAttribute name="slider" />


        <%-- <content>
            <tiles:insertAttribute name="body" />
        </content> --%>
        <%-- <footer>
            <tiles:insertAttribute name="footer" />
        </footer> --%>
    </body>
</html>

Slider.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript">

$(function() {
    $('.banner').unslider();
});
</script>
<body>
    <div class="banner">
        <ul>
            <li><img src='<c:url value="/resources/images/slides/visa.jpg" />'></li>
        </ul>
    </div>
</body>
</html>

If I use same code of slider.jsp in layout.jsp, it is working.


enter image description here

I'm creating a django powered service which would have browser and mobile app clients.

I understand the flow and technical architecture for the browser flow. Browser requests a page from the server and Django serves it (data + template).

But in case of mobile clients, they only need data. In this case how should I serve just the data. I did a research and I got to know that I can django-rest-framework to create apis to serve just the data but I'm still not clear how can I serve requests specific to different clients (page or just the data).

My app was working perfect, due to electricity failure my machine went off and when I on it and run my app on local host it is giving me constantly this error. Can anyone tell me what should I do to fix it ?

Could not load file or assembly 'ChinhDo.Transactions' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Assembly Load Trace: The following information can be helpful to determine why the assembly 'ChinhDo.Transactions' could not be loaded.

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:

[FileLoadException: Could not load file or assembly 'ChinhDo.Transactions' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]

[FileLoadException: Could not load file or assembly 'ChinhDo.Transactions, Version=1.3.0.32, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16 System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'ChinhDo.Transactions, Version=1.3.0.32, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +736
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +284
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

[HttpException (0x80004005): Could not load file or assembly 'ChinhDo.Transactions, Version=1.3.0.32, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9882460 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

I use GridView to show data from DB, in first and second column i use rowspan for join equal cell. Then I add zebra-stripe (rowstyle and alternatingrowstyle), but have a problem for first and second column (see picture). How to fix it? Maybe use identical background for first and second column (but i don't know how to do this)? Maybe something else? ps I use IE8

enter image description here

Are we supposed to be able to follow a AJAX call in the debugger to see what's going on? Because for some reason it seems like the call isn't going to where it's supposed to go to.

When stepping through the program, after the url: '@URL.Action("DidItWork", "Home") call, it goes to:

    public static ApplicationDbContext Create()
    {
        return new ApplicationDbContext();
    }

Followed by several other methods; however, it doesn't appear that it hits any of the lines of code in the DidItWork() action method (based on breakpoints).

I then get Error: Not Found. Status: error. Console: [object Object]

Thoughts/suggestions on how to resolve this issue of the @Url.Action call not setting off any break points in the DidItWork() action method? Because the @Url.Action call isn't getting to the desire effect of having reaching SendEmailAsync().

The following code is in _Layout.cshtml

@*script for someone who presses the send/email button*@ 
<script>
    $("#sendButton").click(function () {
        alert("Send button pressed");
        $.ajax({
            url: '@Url.Action("DitItWork", "Home")',
            success: function (result) {
                alert("Success. It worked: " + result);
            }, 
            error: function( xhr, status, errorThrown ) {
                alert("Sorry, there was a problem! Error: " + errorThrown + ". Status: " + status + ". Console: " + xhr);
                console.log("Hello");
                console.log("Error: " + errorThrown);
                console.log("Status: " + status);
                console.dir(xhr);
                console.log("Good-bye");
            },
        });
        return false;
    });
</script>

The following code is in HomeController.cs

[AllowAnonymous]
public async Task<ActionResult> DidItWork()
{
        var dash = "dash equals nash";

        var manager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
        var user = new ApplicationUser { UserName = "test2 username2", Email = "testemail2@gmail.com" };
        var result = await manager.CreateAsync(user, "passwordGoesHere1!");
        if (result.Succeeded)
        {
            await manager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account");

            return View();
        }

        //AddErrors(result);
        return View();    
}

my database class got a reference to my wcf.

But how can i get load my database info to my mvc project with a wcf service connection ?

I have following function in my Generic Repository. I have two issues with line var list = query.ToPagedList(pageNumber, pageSizeNumber);

public IEnumerable<T> GetPagedListDbContext(string searchFieldName, string searchText, string searchOperator, string sortFieldName, int? page, int? pageSize)
    {
        int pageSizeNumber = (pageSize ?? 20);
        int pageNumber = (page ?? 1);
        string sql = string.Empty;

        sql = string.Format("Select * From {0} q ", typeof(T).Name);
        switch (searchOperator)
        {
            case "Starts With":
                sql += string.Format("Where q.{0} like '{1}%' ", searchFieldName, searchText);
                break;
            case "Ends With":
                sql += string.Format("Where q.{0} like '%{1}' ", searchFieldName, searchText);
                break;
            case "Contains":
                sql += string.Format("Where q.{0} like '%{1}%' ", searchFieldName, searchText);
                break;
            case "Equal To":
                sql += string.Format("Where q.{0} == '{1}' ", searchFieldName, searchText);
                break;
            case "Not Equal To":
                sql += string.Format("Where q.{0} != '{1}' ", searchFieldName, searchText);
                break;
        }

            if (sortFieldName == null)
            {
                sql += "Order By q.Id ";
            }
            else
            {
                sql += string.Format("Order By q.{0} ", sortFieldName);
            }

            // RepoDbSet is DbSet
            DbSqlQuery<T> query = RepoDbSet.SqlQuery(sql);
            var list = query.ToPagedList(pageNumber, pageSizeNumber);

            return list;
        } 
  1. It returns all records from table. (Sql trace below)
  2. It execute same query twice.

    Sql Trace Event Class Text Data

    RPC:Completed exec sp_reset_connection

    SQL:BatchCompleted Select * From Book q Order By q.Id

    RPC:Completed exec sp_reset_connection

    SQL:BatchCompleted Select * From Book q Order By q.Id

    Trace stopped

Questions: Why executing query without Skip and Take (e.g. OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY)?

Why executing twice?

When I checked last line return list it has total count 20 not total rows in table and not hitting database again. how it is querying?

Is it possible to do same process using Linq?

@Html.ValidationSummary(false, string.Empty, new { @class = "text-danger" })

Is it possible to set the DisplayMode from ValidationSummaryDisplayMode.BulletList to ValidationSummaryDisplayMode.SingleParagraph in Razor?