I am working on an ASP.net MVC website with Identity for security and login. I more or less know the basics of working with ASP.net Identity but a problem I have is that I have no idea of how it access the database form the connection-string.

To clarify my question: how does ASP.net Identity access the database and should I use the same method?

In my application, Both mvc and web form is present.

But when I open any .aspx page then in Application_Error error is thrown.

The controller for path '/WebResource.axd' was not found or does not implement IController.

The controller for path '/ScriptResource.axd' was not found or does not implement IController.

I tried all these method, but none of them is working.

  • Added at top in RegisterRoutes method.

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });

  • Create a FileTypeConstraint class to check file ext.

.

public class FileTypeConstraint : IRouteConstraint
    {
        private readonly string[] MatchingFileTypes;

        public FileTypeConstraint(string matchingFileType)
        {
            MatchingFileTypes = new[] { matchingFileType };
        }

        public FileTypeConstraint(string[] matchingFileTypes)
        {
            MatchingFileTypes = matchingFileTypes;
        }

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            if (values["url"] != null)
            {
                string path = values["url"].ToString();
                return MatchingFileTypes.Any(x => path.ToLower().EndsWith(x, StringComparison.CurrentCultureIgnoreCase));
            }
            else
            {
                return false;
            }
        }

And added this line at top and bottom both

 routes.MapRoute(
     "Defaultaxd",
      "{*url}",
       new { controller = "Home", action = "Index", id = UrlParameter.Optional },
        new { myCustomConstraint = new FileTypeConstraint(new[] { "axd" }) }
          );

Tried all these links.

HttpHandlers with ASP.NET MVC

ASP.NET MVC routing issue?

Using URL Routing for Web Forms and StopRoutingHandler for Favicon

I have an asp.net reusable control when directly clicking on file is downloaded with file extension .ashx, that happening only on IE, and its working fine on firefox. This is what i' am getting

Please someone help me with my issue using "Blob" in angularJs for downloading excel file. It is working in Chrome and IE10 and 11 but when I used Firefox and IE8&9 there's no popup download that will tell where to save or open it just like in Chrome.

My API data successfully returns the bytes to download but my client-side script cannot download it.

Here is my code in AngularJS:

    $scope.LoadData = function () {
        $scope.yearIsLoading = true;
        reportsService.getAssessmentReports($scope.filter).$promise.then(function (response) {
            if (response != null) {
                var file = new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
                saveAs(file, 'Assessments Report');
                $scope.yearIsLoading = false;
            }
        });
    };

and here is what I got in IE8 and IE9 error:

[IE8 and IE9 Error][1]

and in Firefox I can't see the error but nothings happen after I clicked the export button.

Thanks in advance to someone that can help me with this issue. :)

I want to clear the textboxes and some elements of html with a button, when the user clicks the button it needs to be clear.

I have an ASP.NET MVC application that sends parameters to an R script, the R script then generates a file and puts it in a folder locally. The process works perfectly on my local machine through Visual Studio but goes in and out after I publish and use IIS. Below is how I am initializing R.NET and getting these values from my view via AJAX.

I also have placed both of these PATHs in my system environment variables.

If anyone knows why IIS only works right after I restart my OS and then stops working shortly after I would greatly appreciate it. Seems odd that I have no problems in Visual Studio that I face in IIS.

        [HttpGet]
    public JsonResult Index1(string modelTypes = null, string fileNames = null, string[] locations = null, string lowerLimits = null, string upperLimits = null, string areas = null, string productivities = null, string[] fobs = null)
    {
        @ViewBag.UserName = System.Environment.UserName;
        string userName = @ViewBag.UserName;
        //Declare field parameters
        var strModelTypeValue = modelTypes;
        string strFileName = fileNames;
        var strLocationValue = locations;
        var strLowerLimitValue = lowerLimits;
        var strUpperLimitValue = upperLimits;
        string strAreaValue = areas;
        string strProductivityValue = productivities;
        string strFobValue = fobs.ToString();
        var libraryLocation = "C:/Users/" + userName + "/Documents/R/win-library/3.2";

        string rPath = @"C:\Program Files\R\R-3.3.2\bin\x64";
        string rHome = @"C:\Program Files\R\R-3.3.2";

        //Initialize REngine
        REngine.SetEnvironmentVariables(rPath, rHome);
        REngine engine = REngine.GetInstance();
        engine.Initialize();

        if (fobs.Length > 1)
        {
            strFobValue = string.Join(" ", fobs);
        }
        else
        {
            strFobValue = "ALL";
        }




        //Declare R Script path
        var rScriptPath = "C:/Users/" + userName + "/Documents/R/RWDir/Loop_Optimization.R";

        //Check to see if there was more than one location selected
        if (strLocationValue.Length > 1)
        {

            foreach (var item in strLocationValue)
            {
                //Set string location to each location value in loop
                var strlocation = item;

                //Add values to parameter list
                var myParams = new List<string>
                {       

                    strModelTypeValue,
                    strFileName,               
                    strlocation,                
                    strLowerLimitValue,
                    strUpperLimitValue,
                    strAreaValue,
                    strProductivityValue,
                    strFobValue,
                    libraryLocation

                };

                //Set myParams as arguments to be sent to r script
                engine.SetCommandLineArguments(myParams.ToArray());
                engine.Evaluate("source('" + rScriptPath + "')");
            }

        }
        //Only one location specified, no need to loop
        else
        {
            foreach (var item in strLocationValue)
            {
                //Set string location to each location value in loop
                var strlocation = item;
                var myParams = new List<string>
                {

                    strModelTypeValue,
                    strFileName,
                    strlocation,
                    strLowerLimitValue,
                    strUpperLimitValue,
                    strAreaValue,
                    strProductivityValue,
                    strFobValue,
                    libraryLocation
                };

                engine.SetCommandLineArguments(myParams.ToArray());
                engine.Evaluate("source('" + rScriptPath + "')");
            }
        }
        //engine.Evaluate("source('" + rScriptPath + "')");
        //engine.Dispose();
        return Json("success", JsonRequestBehavior.AllowGet);

    }

i have swapped some css from a project iw as doing into the basic asp web forms template so i could experiment with the user controls and i have tried to implement the code that i did for my master page into the template. the way i did it before was placing all the styling on the master page. i have now placed all the styling into site.css (not sure if this is correct) it looks mostly right but a few things are different and im not sure why:

/* Move down content because we have a fixed navbar that is 50px tall */
body {
    padding-top: 50px;
    padding-bottom: 20px;
}

/* Wrapping element */
/* Set some basic padding to keep content from hitting the edges */
.body-content {
    padding-left: 15px;
    padding-right: 15px;
}

/* Override the default bootstrap behavior where horizontal description lists 
   will truncate terms that are too long to fit in the left column 
*/
.dl-horizontal dt {
    white-space: normal;
}

/* Set widths on the form inputs since otherwise they're 100% wide */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="select"] {
    max-width: 280px;
}

/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
    .jumbotron {
        margin-top: 20px;
    }

}

li {
    border-right: 1px solid #ff6600;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #2B3533;
    border: 1px solid #ff6600;
}

    ul li {
        display: block;
        position: relative;
        float: left;
        background: #2B3533;
    }

li ul {
    display: none;
}

ul li a {
    display: block;
    padding: 1em;
    text-decoration: none;
    white-space: nowrap;
    color: #fff;
}

li:hover > ul {
    display: block;
    position: absolute;
}

li:hover li {
    float: none;
}

li:hover a {
    background: #2B3533;
}

li:hover li a:hover {
    background: #ff6600;
}

.main-navigation li ul li {
    border-top: 0;
}

ul li a:hover {
    background: #ff6600;
}

ul ul ul {
    left: 100%;
    top: 0;
}

ul:before,
ul:after {
    content: " ";
    display: table;
}

ul:after {
    clear: both;
}

That is the current state of site.css and here is my master page code:

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="ComputingProjectwh.SiteMaster" %>

<!DOCTYPE html>

<html lang="en">
<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %> - My ASP.NET Application</title>

    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>
    <webopt:bundlereference runat="server" path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

</head>
<body>
   <form id="form1" runat="server">
        <asp:ScriptManager runat="server">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts--%>
                <asp:ScriptReference Name="MsAjaxBundle" />
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
                <asp:ScriptReference Name="respond" />
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
                <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
                <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
                <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
                <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
                <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
                <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
                <asp:ScriptReference Name="WebFormsBundle" />
                <%--Site Scripts--%>
            </Scripts>
        </asp:ScriptManager>
        <ul class="main-navigation">
            <li><a href="/Home.aspx">Synther Physics</a></li>
            <li><a href="/RevisionTopicList.aspx">Revision by Topic</a>
                <ul>
                    <li><a href="/RevisionPages/1. Further Mechanics/Further Mechanics Topic List.aspx">Further Mechanics</a>
                        <ul>
                            <li><a href="/RevisionPages/1. Further Mechanics/Moments and Energy.aspx">Moments and Energy</a></li>
                            <li><a href="/RevisionPages/1. Further Mechanics/Motion in a Circle.aspx">Motion in a Circle</a></li>
                        </ul>
                    </li>
                    <li><a href="/RevisionPages/2. Gravitaional Fields/Universal Gravitation.aspx">Gravitaional Fields</a>
                        <ul>
                            <li><a href="/RevisionPages/2. Gravitaional Fields/Universal Gravitation.aspx">Universal Gravitation</a></li>
                        </ul>
                    </li>
                    <li><a href="/RevisionPages/3. Electric and Magnetic Fields/Electric and Magnetic Fields Topic List.aspx">Electric and Magnetic Fields</a>
                        <ul>
                            <li><a href="/RevisionPages/3. Electric and Magnetic Fields/Capacitance.aspx">Capacitance</a></li>
                            <li><a href="/RevisionPages/3. Electric and Magnetic Fields/Electric Fields.aspx">Electric Fields</a></li>
                            <li><a href="/RevisionPages/3. Electric and Magnetic Fields/Magnetic Fields.aspx">Magnetic Fields</a></li>
                        </ul>
                    </li>
                    <li><a href="/RevisionPages/4. Nuclear and Particle Physics/Nuclear and Particle Physics Topic List.aspx">Nuclear and Particle Physics</a>
                        <ul>
                            <li><a href="/RevisionPages/4. Nuclear and Particle Physics/Electrons and Nuceli.aspx">Electrons and Nuclei</a></li>
                            <li><a href="/RevisionPages/4. Nuclear and Particle Physics/Particle Physics.aspx">Particle Physics</a></li>
                        </ul>
                    </li>
                    <li><a href="/RevisionPages/5. Nuclear Radiation/Nuclear Decay.aspx">Nuclear Radiation</a>
                        <ul>
                            <li><a href="/RevisionPages/5. Nuclear Radiation/Nuclear Decay.aspx">Nuclear Decay</a></li>
                        </ul>
                    </li>
                    <li><a href="/RevisionPages/6. Thermodynamics/Thermodynamics Topic List.aspx">Thermodynamics</a>
                        <ul>
                            <li><a href="/RevisionPages/6. Thermodynamics/Gas Laws and Kinetic Theory.aspx">Gas Laws and Kinetic Theory</a></li>
                            <li><a href="/RevisionPages/6. Thermodynamics/Internal Energy, Absolute Zero and Change of State.aspx">Internal Energy, Absolute Zero and Change of State</a></li>
                            <li><a href="/RevisionPages/6. Thermodynamics/Specific Heat Capacity.aspx">Specific Heat Capacity</a></li>
                        </ul>
                    </li>
                    <li><a href="/RevisionPages/7. Space/Space Topic List.aspx">Space</a>
                        <ul>
                            <li><a href="/RevisionPages/7. Space/Astrophysics.aspx">Astrophysics</a></li>
                            <li><a href="/RevisionPages/7. Space/Cosmology.aspx">Cosmology</a></li>
                        </ul>
                    </li>
                    <li><a href="/RevisionPages/8. Oscillations/Oscillations.aspx">Oscillations</a>
                        <ul>
                            <li><a href="/RevisionPages/8. Oscillations/Oscillations.aspx">Oscillations</a></li>
                        </ul>
                    </li>
                </ul>
            </li>
            <li><a href="/RevisionTestList.aspx">Tests by Topic</a>
                <ul>
                    <li><a href="/TestPages/1. Further Mechanics/Further Mechanics Test List.aspx">Further Mechanics</a>
                        <ul>
                            <li><a href="/TestPages/1. Further Mechanics/Moments and Energy Test.aspx">Moments and Energy</a></li>
                            <li><a href="/TestPages/1. Further Mechanics/Motion in a Circle Test.aspx">Motion in a Circle</a></li>
                        </ul>
                    </li>
                    <li><a href="/TestPages/2. Gravitaional Fields/Universal Gravitation Test.aspx">Gravitaional Fields</a>
                        <ul>
                            <li><a href="/TestPages/2. Gravitaional Fields/Universal Gravitation Test.aspx">Universal Gravitation</a></li>
                        </ul>
                    </li>
                    <li><a href="/TestPages/3. Electric and Magnetic Fields/Electric and Magnetic Fields Test List.aspx">Electric and Magnetic Fields</a>
                        <ul>
                            <li><a href="/TestPages/3. Electric and Magnetic Fields/Capacitance Test.aspx">Capacitance</a></li>
                            <li><a href="/TestPages/3. Electric and Magnetic Fields/Electric Fields Test.aspx">Electric Fields</a></li>
                            <li><a href="/TestPages/3. Electric and Magnetic Fields/Magnetic Fields Test.aspx">Magnetic Fields</a></li>
                        </ul>
                    </li>
                    <li><a href="/TestPages/4. Nuclear and Particle Physics/Nuclear and Particle Physics Test List.aspx">Nuclear and Particle Physics</a>
                        <ul>
                            <li><a href="/TestPages/4. Nuclear and Particle Physics/Electrons and Nuceli Test.aspx">Electrons and Nuclei</a></li>
                            <li><a href="/TestPages/4. Nuclear and Particle Physics/Particle Physics Test.aspx">Particle Physics</a></li>
                        </ul>
                    </li>
                    <li><a href="/TestPages/5. Nuclear Radiation/Nuclear Decay Test.aspx">Nuclear Radiation</a>
                        <ul>
                            <li><a href="/TestPages/5. Nuclear Radiation/Nuclear Decay Test.aspx">Nuclear Decay</a></li>
                        </ul>
                    </li>
                    <li><a href="/TestPages/6. Thermodynamics/Thermodynamics Test List.aspx">Thermodynamics</a>
                        <ul>
                            <li><a href="/TestPages/6. Thermodynamics/Gas Laws and Kinetic Theory Test.aspx">Gas Laws and Kinetic Theory</a></li>
                            <li><a href="/TestPages/6. Thermodynamics/Internal Energy, Absolute Zero and Change of State.aspx">Internal Energy, Absolute Zero and Change of State</a></li>
                            <li><a href="/TestPages/6. Thermodynamics/Specific Heat Capacity.aspx">Specific Heat Capacity</a></li>
                        </ul>
                    </li>
                    <li><a href="/TestPages/7. Space/Space Test List.aspx">Space</a>
                        <ul>
                            <li><a href="/TestPages/7. Space/Astrophysics Test.aspx">Astrophysics</a></li>
                            <li><a href="/TestPages/7. Space/Cosmology.aspx">Cosmology</a></li>
                        </ul>
                    </li>
                    <li><a href="/TestPages/8. Oscillations/Oscillations Test.aspx">Oscillations</a>
                        <ul>
                            <li><a href="/TestPages/8. Oscillations/Oscillations Test.aspx">Oscillations</a></li>
                        </ul>
                    </li>
                </ul>
            </li>
            <li><a href="/Formula Analysis.aspx">Formula Analysis</a></li>
            <li><a href="/Sylabus Breakdown.aspx">Sylabus Breakdown</a></li>
            <asp:LoginView runat="server" ViewStateMode="Disabled">
                <AnonymousTemplate>
                    <ul class="nav navbar-nav navbar-right">
                        <li><a runat="server" href="~/Account/Register">Register</a></li>
                        <li><a runat="server" href="~/Account/Login">Log in</a></li>
                    </ul>
                </AnonymousTemplate>
                <LoggedInTemplate>
                    <ul class="nav navbar-nav navbar-right">
                        <li><a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName()  %>!</a></li>
                        <li>
                            <asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
                        </li>
                    </ul>
                </LoggedInTemplate>
            </asp:LoginView>
        </ul>
        <div>
            <asp:ContentPlaceHolder ID="MainCOntent" runat="server">
            </asp:ContentPlaceHolder>
            <footer>
                <p>&copy; <%: DateTime.Now.Year %> - Synther Physics</p>
            </footer>
        </div>
    </form>
</body>
</html>

I am trying to make it so that it looks like this: Drop down however it currently looks like this: broken dropw down

where the link is blue and underwritten

If anyone can see how I can sort this or tell me that would be a real help.

Thanks

I have a following problem with my NHibernate One-to-many mappings. If I want to get all Customers, by my API methods, I get a following error:

"$id":"1","Message":"An error has occurred.","ExceptionMessage":"The 'ObjectContent`1' type failed to serialize the response body for content type 'text/html; charset=utf-8'.","ExceptionType":"System.InvalidOperationException","StackTrace":null,"InnerException":{"$id":"2","Message":"An error has occurred.","ExceptionMessage":"could not initialize a collection: [Designet.Models.Customer.Orders#1][SQL: SELECT orders0_.CustomerId as Custom2_2_1_, orders0_.Id as Id1_2_1_, orders0_.Id as Id1_2_0_, orders0_.CustomerId as Custom2_2_0_, orders0_.Description as Descri3_2_0_, orders0_.Price as Price4_2_0_, orders0_.Created as Create5_2_0_, orders0_.Deadline as Deadli6_2_0_ FROM Order orders0_ WHERE orders0_.CustomerId=?]","ExceptionType":"NHibernate.Exceptions.GenericADOException","StackTrace":" w NHibernate.Loader.Loader.LoadCollection(ISessionImplementor session, Object id, IType type)\r\n

Underneath I pasted my codes. I was looking for answer for my problem on google and SO, but nothing, what people proposed, helped. I don't understand which part of code throw an error. Maybe you have some proposition, what should I do, to solve the problem? I will very glad for your help.

Customer model:

public class Customer
    {
        public virtual int Id { get; set; }
        public virtual string Name { get; set; }

        public virtual IList<Order> Orders { get; set; }

        public Customer()
        {
            Orders = new List<Order>();
        }
    }

Customer Mappings:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"
                   assembly="Designet" namespace="Designet.Models">
  <class name="Customer" table="Customer" dynamic-update="true" lazy="true" >
    <cache usage="read-write"/>
    <id name="Id" column="Id" type="int">
      <generator class="native" />
    </id>
    <property name="Name" />
    <bag name="Orders" lazy="true" inverse="true" >
      <key column="CustomerId"/>
      <one-to-many class="Designet.Models.Order"/>
    </bag>    
  </class>
</hibernate-mapping>

Customer Database:

CREATE TABLE [dbo].[Customer] (
    [Id]   INT            IDENTITY (1, 1) NOT NULL,
    [Name] NVARCHAR (255) NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC)
);

Order Model:

 public class Order
    {
        public virtual int Id { get; set; }
        public virtual string Description { get; set; }
        public virtual decimal Price { get; set; }
        public virtual DateTime Created { get; set; }
        public virtual DateTime Deadline { get; set; }

        public virtual int CustomerId { get; set; }
        public virtual Customer Customer { get; set; }

    }

Order Mappings:

    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"
                   assembly="Designet" namespace="Designet.Models"
    <class name="Order" table="Order" dynamic-update="true" lazy="true" > 
    <cache usage="read-write"/>
    <id name="Id" column="Id" type="int">
      <generator class="native" />
    </id>

    <many-to-one name="Customer" column="CustomerId"/>

    <property name="Description" />
    <property name="Price" />
    <property name="Created" />
    <property name="Deadline" />
    <property name="CustomerId" not-null="true" />

  </class>
</hibernate-mapping>

Order Database:

CREATE TABLE [dbo].[Order] (
    [Id]          INT            IDENTITY (1, 1) NOT NULL,
    [Description] NVARCHAR (MAX) NULL,
    [Price]       SMALLMONEY     NULL,
    [Created]     DATETIME       NOT NULL,
    [Deadline]    DATETIME       NULL,
    [CustomerId]  INT            NOT NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC),
    FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id])
);

i'm new with asp.net and mvc, i'm trying to send a int, a list of int from a different object, and other list of ints from a other object, with a form.

my view for insert the int is

@using (Html.BeginForm("Guardar", "pedidoEmp"))
{
    @Html.ValidationSummary(true, "Please fix the following errors.")
    <center>
        <div class="form-group">
            @Html.LabelFor(m => m.empleadoId)
            @Html.DropDownListFor(m => m.empleadoId, new SelectList(Model.verEmp, "empleadoId", "Nombre"), "", new { @class = "form-control" })
            @Html.ValidationMessageFor(m => m.empleadoId)
        </div>
    </center>

and the list are

@for (var i = 0; i < Model.verMenu.Count; i++)
    {
        <tr>

            <td>
                    @Html.HiddenFor(menuId => Model.verMenu[i].MenuId)

                @Html.DisplayFor(sopa => Model.verMenu[i].Sopa)
            </td> 

. . .

  <div class="form-group">

                        @for (var o = 0; o < Model.opMenuVer.Count; o++)
                        {
                            if (Model.opMenuVer[o].MenuId == Model.verMenu[i].MenuId)
                            {
                                @Html.CheckBox("OpcionId", new { value = Model.opMenuVer[o].OpcionId })
                                @Html.Label(Model.opMenuVer[o].Nombre)
                                @Html.ValidationMessageFor(m => Model.opMenuVer[o].OpcionId)
                            }
                        }

                    </div>
</td>
        </tr>
    }
            </tbody>
        </table>
        @Html.AntiForgeryToken()
        <button type="submit" class="btn btn-primary">Guardar</button>
    }

in my controller the httppost i try to do something like this

[HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Guardar(int idEmp, List<int> menusId, List<int> opsId)
        {
            List<PedidoXEmpleados> pedido = new List<PedidoXEmpleados>(); 
            if (!ModelState.IsValid)
            {
                return View("agregarMenu");
            }
            for (int i = 0; i < menusId.Count; i++)
            {
                pedido[i].estadoPedido = true;
                pedido[i].EmpleadoId = idEmp;
                pedido[i].MenuId = menusId[i];
                pedido[i].OpcionId = opsId[i];
                _conBd.PedidoXEmpleados.Add(pedido[i]);
            }

            _conBd.SaveChanges();
            return RedirectToAction("Index");
        }

thank you very much, i try to search for other parts and i didn't find something that works, when i try the project show me this, "The parameters dictionary contains a null entry for parameter 'idEmp' of non-nullable type".

I'm new to ASP.NET. I have the following code, but I don't know where to place the asp:UpdatePanel control, its contenttemplate and (if needed) its triggers, so I can have a validation without postback?

 <form method="post" id="formLogin" runat="server">
    <asp:ScriptManager runat="server">
        <Scripts>
            // bunch of scriptreferences
        </Scripts>
    </asp:ScriptManager>

                <p>
                    <asp:Label ID="lblEmail" runat="server" Text="Email:"/><br/>
                    <asp:TextBox ID="txtEmail" runat="server"/>
                </p>
                <p>
                    <asp:Label ID="lblPassword" runat="server" Text="Password:"/><br/>
                    <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"/>
                </p>

        <div id="msg" runat="server" class="item">

                    <asp:Label ID="lblMessage" runat="server" ForeColor="Red" />
                </div>

                <div class="loginbutton">
                    <p>
                        <a href="#" class="forgot">Forgot Password?</a><br />
                        <a href="../EN/form_1.aspx" class="forgot">New user?</a>
                    </p>
                    <input type="reset" name="login" value="Cancel" id="cancel" />

                    <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />
                </div>
    </form>

The lblMessage shows up as "You have entered incorrect email/password" if the credentials don't match database records.

I have a page where users can search for sales rep. Once they are on the a Rep's detail page, the browser back button gives the 'confirm submission' error. the dotNet dev says there isn't a fix, so i'm looking at a JS solution.

Ideally, I want the browser to take the user back to the search page, worst case, disable the back button.

I've hit the Google, as was reading this: https://css-tricks.com/using-the-html5-history-api/ on using the html 5 history.api, but this doesn't seem to do what i'm hoping for.

Is it possible to have the back button act like a navigation button?

The production site is here: https://www.knowledgefirstfinancial.ca/ and the Find a Rep page is here: http://dev.knowledgefirstfinancial.ca/find-a-rep.aspx

I have been following this page; http://www.ryadel.com/en/setup-a-multi-language-website-using-asp-net-mvc/ to make my site support multiple cultures.

the code all compiles and runs, but it seems to be ignoring my culture specific resx files.

Right now the test is pretty superficial, and I simply have 2 resource files; Resources.resx and Resources.au.resx

My template is calling @Resources.PageFooter which is the only string defined in both files.

If I browse to http://mysite/index and inspect the page footer it contains my default value. If I change my url to http://mysite/au/index then it still displays the default value. However inspecting CurrentThread.CurrentUICulture and CurrentThread.CurrentCulture shows that both are now set to au, but it is still picking up and using Resources.resx not Resources.au.resx

My Resource files are in a separate folder Resources, as the article suggests.

So I am stuck.

After some investigation, I have found that if I create another resx file (for Italian), then that works.

So it looks like the files that are being ignored are the 'variations' such as American English, Australian English and so on.

I have a form where the user can add some sort of categories and add some options to those categories. When the user enter the data for the category and its items, I dynamically add them in a <select>, where the category is the <optgroup>, so I can bind it to some ViewModel property, it looks like this after the user entered the data:

<select asp-for="Items">
   <optgroup label="Brands">
       <option value="Brand1">Brand1</option>
       <option value="Brand2">Brand2</option>
       <option value="Brand3">Brand3</option>
       <option value="Brand4">Brand4</option>
   </optgroup>
   <optgroup label="Something">
       <option value="Something1" selected>Something1</option>
       <option value="Something2" selected>Something2</option>
       <option value="Something3" selected>Something3</option>
       <option value="Something4" selected>Something4</option>
   </optgroup>
</select>

Then I try to bind this to the Items property in the ViewModel, but the only way I can bind this, is with the Items of the type List<string>. This way I lost the Group each option belongs to. How could I bind it for something like a Dictionary<string, List<string>> where I can keep the grouping that I did on the html?

PS.: The select will be invisible, its only a way for me to get the data in some structure that I can submit in a form. The presentation will be done in some sort of tags. Like:

enter image description here

I am trying to render the name of an uploaded file without displaying the full url path i.e. replace '/portal/documents/Doc1.docx' with 'Doc1'. I am using the razor template files that come with the install package and my razor file field is called 'q.Link'. From screenshot, I want to display file name only from 'File:673'.

enter image description here

Also, is there a way to auto display the selected font awesome icon from the 'FileType' option above? Is it possible to display a certain icon if a certain file is uploaded i.e. .docx uploaded then 'fa-file-word-o' displays to screen just left of file name 'Doc1' (currently I am getting user to select an icon from a dropdown list but looking to skip this hopefully unnecessary step)?

So heres my question. I have a Asp.net application with a form based authentication. I have users in my database but the users also has to be in the active directory.

The following code is for me to check if user is in the domain A

            DirectoryEntry de = new DirectoryEntry();
            de.Path = "LDAP://domainA.com";
            de.AuthenticationType = AuthenticationTypes.None;
            DirectorySearcher search = new DirectorySearcher(de);
            search.Filter = "(SAMAccountName=" + account + ")";
            search.PropertiesToLoad.Add("displayName");

            SearchResult result = search.FindOne();

This code work fine. The problem is client is requesting that domain B should also be able to connect to the application. So created the following code:

            DirectoryEntry de = new DirectoryEntry();
            de.Path = "LDAP://domainB.com";
            de.AuthenticationType = AuthenticationTypes.None;
            DirectorySearcher search = new DirectorySearcher(de);
            search.Filter = "(SAMAccountName=" + account + ")";
            search.PropertiesToLoad.Add("displayName");

            SearchResult result = search.FindOne();

Since my server is in domainA this does not work. Is there a way for me to query domainB knowing that the server is in domainA? I found an article saying trust needs to be setup for domainA and B but this domains shouldnt be linked. Its only for this application that they need this functionality.

P.S. I might forgot to explain an important detail. domainA and B are not on the same network. But domainA can ping domainB

I have created complete template driven form in angular2 with user input control, and calls to web api with visual studio code for all form needs. It is completely "independent". The question is: Is it possible to add this form to existing .aspx (visual studio) form? For example:

 <standard page aspx/html code/>
 <myangularForm></myangularForm>
 <rest of the standard page code/>

Primarily I need this because I have a button in the "rest of the standard page code" who redirect me to a page who give telerik pdf report....and don't want to change that now, and it would be easy to rewrite my project with great new angular2 forms, and keep my all existing .aspx form.

King regards,

I am using selectpdf library to create pdf from html. I am able to create it successfully but when i deployed my project on server it is not creating pdf just 2 blank pages, but if i remotely access the server and while staying on that server and run the application with localhost it successfully creates the pdf. I thought its permission issues so i shutdown the firewall as well but still nothing happen. Any help will be appreciated, please ask me if i am not clear i know its quite confusing.

I have this piece of code in my View which belongs to a form

<div class="col-md-10">
@foreach (var l in leads)
{
    @: @Html.CheckBox("cbLead", false, new { @value = @l.Id }) @Html.TextBox("worth", "") - @Html.Label(l.Name)
}
</div>

And this is the form with I handle the post:

[HttpPost]
public ActionResult Update(string[] cbLead, double[] worth)
{
    // code
}

I have 24 checkboxes, but for each checkbox selected I receive 2 values in the Update method. So for example if I select 3 out of that 24 checkboxes, I receive 27 values in the string[] cblead.

Example with 24 checkboxes:

3 first checkboxes selected

And this is what I get in the method:

enter image description here

So I receive the value checked and an added false after. Any tips?

I have an MVC app in which after I chose the value from dropdown menu the function is executed in which sql is handled. The dropdown is at:

http://localhost:9030/Courses/Index

And after I make a selection the result is at:

http://localhost:9030/Courses/getCoursesByTeachers?Teacher=(here is an ID of the element)

getCoursesByTeachers is the function in my controller which takes the ID as the parameter.

Here is the function:

public string getCoursesByTeachers(int Teacher)
        {
            string sql = "SELECT * FROM Course WHERE teacher_Id = @Teacher";
            string connectionString = "Data Source=TSSKKEWKS0619;Initial Catalog=T-Timetable;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
            //string course = "No courses are being taught by this teacher";
            List<string> list = new List<string>();
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("Teacher", Teacher);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        list.Add(reader["name"].ToString());
                    }
                }
                finally
                {
                    reader.Close();
                }
            }
            if (list.Count==0)
            {
                list.Add("There are no courses being taught by this teacher.");
            }

            return string.Join(System.Environment.NewLine, list);
        } 

And here is how I call it in my cshtml:

<h2>Courses taught by:</h2>

    @using (Html.BeginForm("getCoursesByTeachers", "Courses", FormMethod.Get))
    {
        @Html.DropDownList("Teacher", (SelectList)ViewBag.Teacher, "Select teacher", new { onchange = @"form.submit()" }); // form.action('getCoursesByTeacher')
    }

Is there a way of modifiying it so the result is not shown at the redirected page but within the same one in the url at: http://localhost:9030/Courses/Index. (maybe like underneath it or so, I am guessing I have to change it somehow in the cshtml right? I cant figure out how and I don't want to screw it up when it works :D so I figured I ask you guys)

Hope the question was clear enough. Thank you for any help.

I've used the last couple of days searching Google & here on Stack, but cant seem to find a suitable solution for my problem.

I'm currently developing a web application using ASP.NET following the MVC pattern & currently using mySQL as DB. I have followed this article briefly to implement user login features: http://benfoster.io/blog/aspnet-identity-stripped-bare-mvc-part-1. All users have an attribute which defines their role.

My next step is to limit all Admin features in my AdminController to Admin only user(s). But it seems that all solutions rely on using the "Microsoft.AspNet.Identity.EntityFramework" package. I do however not use Entity at all, why? Because I like to be in control of my queries & like to write them my self so Entity is not the answer here, I use ADO.net.

My question: How do I implement simple user roles so that I can use the "[Authorize(Roles = "Admin")]" attribute on my controller, without using the Entity framework and only working with OWIN.

I am using selectpdf library to create pdf from html. I am able to create it successfully but when i deployed my project on server it is not creating pdf just 2 blank pages, but if i remotely access the server and while staying on that server and run the application with localhost it successfully creates the pdf. I thought its permission issues so i shutdown the firewall as well but still nothing happen. Any help will be appreciated, please ask me if i am not clear i know its quite confusing.