Starting April 19, 12:40pm, 3 of our webapps hosted by azure (asp.net 64bit 4.7) started throwing random error 400 and 500, going down for 5 minutes every once in a while.

This is happening in the East US, North Europe and Australia East centers.

Needless to say, the web app was not modified in the past month.

We are getting these errors even on simple resource files like JS and CSS.

For example: https://apps.kwizcom.com/Products/APLFE/Scripts/kwizcom.aplfe.controller.core.js?rev=1.1.0.9

Would log this error: HTTP Error 400.0 - Bad Request ASP.NET detected invalid characters in the URL.

Other requests (mostly to web REST api) will return: "The request could not be understood by the server due to malformed syntax."

Making the exact same request right after will return the content as expected.

And every now and then an error 500 will come up, usually bringing down the server for a short while.

Any clue why this could be happening? Feels like a new feature rolled out in Azure that causes this - anyone else experiencing the same issues?

Any insight or workaround will be greatly appreciated.

Current project:

  • ASP.NET 4.7
  • MVC 5
  • C# 7

I have been looking into WkHtmlToPdf, but one of the primary issues I have discovered with it is that it needs to access web pages as full URLs outside of any authentication scheme (available to world+dog) in order to convert them to PDF. As in, it does not seem to convert the PDF in the context of the currently logged-in user.

This means that any page behind a login is largely inaccessible, especially if that page uses user session variables to populate its content; as does the pages I am looking to convert to PDF.

My one option is to convert the View to a string (which allows me to use the currently logged-in user’s session variables to create the content), however I can’t seem to figure out if WkHtmlToPdf can accept images as byte arrays (like Firefox can) or if it requires them to be external resources (pointing to an image file).

I am hoping to have both pages as well as images within a fully authenticated part of the site, so any assistance with any form of PDF conversion would be greatly appreciated.

The pages I want to convert are to be assembled in traditional MVC5 Views, as this will allow me to fully populate them using the appropriate models. However, both pages and the images that are loaded into these pages require both authorization to view, as well as a number of session variables that are specific to the user that is logged in (tied to the user triggering the PDF generation).

I am newbie to WEB API2 and JSON overall. I have a JSON body like this

{
  "Input_data": {
     "method": "check",
     "hashcode": " xxxxxx ",
     "accountId": "11111111",
  }
}

How could I retrieve values from POST request?

I have model like this

 [JsonArray]
 public class BaseInput
 {       
    [JsonProperty(PropertyName = "method")]
    public  string Method { get; set; }

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

    [JsonProperty(PropertyName = "accountid")]
    public int accountId { get; set; }
}

And controller code like this

BaseOutput ApiReqeust(int partnerId,[FromBody] BaseInput Input_data)

And Input_data is always null.

What am I doing wrong?

I'm using .net core 2 as backend and Angular2 as frontend for this app. I encountered the issue where I need to check whether price difference between products in other shops are greater than price in BaseEshop for e.g. 10%, if yes then I need to change that '' background-color to red. There are like 100 products in each eshop which I need to check and change the background color

What is the best way to do it. This is my code:

import { ProductService } from './../../services/product.service';
import { Product } from './../../models/product';
import { Component, OnInit } from '@angular/core';
import { ToastyService } from 'ng2-toasty';
import { Router, ActivatedRoute } from '@angular/router';
import { Price } from '../../models/price';

@Component({

    templateUrl: 'product-list.html'
  })

  export class ProductListComponent implements OnInit {

        product: Product[];
        prices: Price[];

        constructor(private productService: ProductService) { }

        ngOnInit() {
            this.productService.getProducts().subscribe(product => this.product = product);
            this.productService.getPrices().subscribe(prices => this.prices = prices);

        }
      }

Here is html file

<table class="table">
        <thead>
                <tr>

                  <th>Code</th>
                  <th>Name</th>
                  <th>BaseEshop</th>
                  <th>Eshop2</th>
                  <th>Eshop3</th>
                  <th>Eshop4</th>
                  <th>Eshop5</th>
                  <th></th>
                </tr>
            </thead>
    <tbody>
    <tr *ngFor="let p of product" >

      <td>{{ p.code }}</td>
      <td >{{ p.name }}</td> 
    <ng-container *ngFor="let pr of p.prices">
      <td *ngIf=" pr.eshopId==1" >{{ pr.value }}</td>
      <td *ngIf=" pr.eshopId==2" >{{ pr.value }}  <span class='glyphicon glyphicon-arrow-up'></span></td>

      <td *ngIf=" pr.eshopId==3" >{{ pr.value }}</td>
      <td *ngIf=" pr.eshopId==4" >{{ pr.value }}</td>
      <td *ngIf=" pr.eshopId==5" >{{ pr.value }}</td>
      </ng-container>
    </tr>

  </tbody>
</table>

This what my json looks like

 {
            "id": 218374,
            "name": "\"Dell Inspiron 15 5578 Silver, 15.6 \"\", Touchscreen, Full HD, 1920 x 1080 pixels, Gloss, Intel Core i5, i5-7200U, 8 GB, DDR4, SSD 256 GB, Intel HD, Linux, 802.11ac, Bluetooth version 4.2, Keyboard language English, Keyboard backlit\"",
            "code": "272771020",
            "edited": false,
            "prices": [
                {
                    "id": 448664,
                    "value": "929.79",
                    "updatedAt": "2018-04-16T22:41:59",
                    "eshopId": 1
                },
                {
                    "id": 490139,
                    "value": "811.00",
                    "updatedAt": "2018-04-20T11:42:26",
                    "eshopId": 2
                },
                {
                "id": 490789,
                "value": "781.00",
                "updatedAt": "2018-04-20T11:22:42",
                "eshopId": 3
            }
        ]
}

Let me start with saying that I do not have access to the source code or project of this website, I was brought on to attempt to help move this site over without recompiling the site. The goal is to get this site compliant with TLS 1.2 in order to maintain credit card payment functionality that will be cut off soon if not using TLS 1.2

With all that being said when changing the app pool to 4.0 I run into the expected "there is a duplicate 'system.web.extensions/scripting/scriptresourcehandler' section defined" error. My research has shown that I need to remove the sectionGroup that contains the system.web.extensions as in 4.0 they are already in the machine.config. This does resolve my first error but now the site 404s when attempting to browse it both locally and externally. Would anyone be able to offer additional insight on how I may accomplish this?

I hosted my .net core application in IIS. Application is working fine at the developing environment and after that i publish the site and configure it on IIS server. I also installed DotNetCore.2.0.5-WindowsHosting for making My application to work with IIS. After i hosted my site and try to browse the site then it is showing that 500 Error. Then i had gone through the logs file then logs is showing error like this

**

warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]
      Using an in-memory repository. Keys will not be persisted to storage.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[59]
      Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
      Creating key {1081fa4f-bf4d-4c0e-811f-cbc0714094a6} with creation date 2018-04-20 09:19:48Z, activation date 2018-04-20 09:19:48Z, and expiration date 2018-07-19 09:19:48Z.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {1081fa4f-bf4d-4c0e-811f-cbc0714094a6} may be persisted to storage in unencrypted form.
Hosting environment: Production
Content root path: D:\Publish
Now listening on: http://localhost:23104
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:8081/  
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method CISIV.Web.Controllers.HomeController.Index (CISIV.Web) with arguments ((null)) - ModelState is Valid
fail: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[3]
      The view 'Index' was not found. Searched locations: /Views/Home/Index.cshtml, /Views/Shared/Index.cshtml
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action CISIV.Web.Controllers.HomeController.Index (CISIV.Web) in 33.6507ms
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
      An unhandled exception has occurred: The view 'Index' was not found. The following locations were searched:
      /Views/Home/Index.cshtml
      /Views/Shared/Index.cshtml
System.InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Home/Index.cshtml
/Views/Shared/Index.cshtml
   at Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable`1 originalLocations)
   at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeResultAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method CISIV.Web.Controllers.HomeController.Error (CISIV.Web) with arguments ((null)) - ModelState is Valid
fail: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[3]
      The view 'Error' was not found. Searched locations: /Views/Home/Error.cshtml, /Views/Shared/Error.cshtml
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action CISIV.Web.Controllers.HomeController.Error (CISIV.Web) in 3.0263ms
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
      An exception was thrown attempting to execute the error handler.
System.InvalidOperationException: The view 'Error' was not found. The following locations were searched:
/Views/Home/Error.cshtml
/Views/Shared/Error.cshtml
   at Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable`1 originalLocations)
   at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeResultAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLD6JVENBQ42", Request id "0HLD6JVENBQ42:00000001": An unhandled exception was thrown by the application.
System.InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Home/Index.cshtml
/Views/Shared/Index.cshtml
   at Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable`1 originalLocations)
   at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeResultAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.<Invoke>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.<ProcessRequestsAsync>d__2.MoveNext()
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 377.3418ms 500 
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 POST http://127.0.0.1:23104/iisintegration  0
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 0.3096ms 202 
Application is shutting down...

**

I googled it but cannot find proper solution so please help me to get rid out of this problem.

I am readng the data from input CSV files and passing to server.

After selecting the input files, when we click on the Submit button, I am reading the data from this selected CSV input file as below.

Here we are using Jquery CSV method to read the CSV file data. When the file has 10,000 records, it is working fine.

Now I am testing for 50,000 records. It is not working. Developer Tools is crashing in the case of 58K records when i execute the below line of code. It is displaying error as "Something went wrong while displaying this webpage" and displaying the blank page with this error.

How to increase the size here? Anyone came across this issue? We are using Jquery.csv.js plugin.

Developer Tools Error is: Dev Tools was disconnected from the Page. Once page is reloaded, DevTools will automatically reconnect.

This is the code i have.

 var inputFileData = $.csv.toObjects(importDataFromFiles[0].data)

Thanks

I'm building an application in Unity-C#, where everything is referenced under an App class in an MVC pattern. An App instance will make use of several Service classes for doing different data-related things, and all of these Service classes derive from Service.ServiceAbstract, which only contains a basic constructor as well as a Getter for a reference to the relevant App instance.

Ideally what I want is for the App instance to itself create and store all of the services in some kind of container, as well as have a Getter method to return a reference to a requested service. Currently, it is done like this;

private Dictionary<Service.ServiceNames, Service.ServiceAbstract> _services = null;

public Service.ServiceAbstract GetService(Service.ServiceNames serviceName)
{
    return _services[serviceName] as Service.ServiceAbstract;
}

The problems I'm having with this implementation are twofold;

  1. Service.ServiceNames is an enum, which increases the maintainability requirement every time a new Service class has to be created.
  2. The way to retrieve a method inside one of these services looks like this;

    ((Service.AudioService)[Service.ServiceNames.AUDIO]).DoSomething();

    This becomes unwieldy when I need to pass data from one service to another;

    ((Service.ErrorService)[Service.ServiceNames.ERROR]).CreateErrorPopup(((Service.LocaleService)[Service.ServiceNames.LOCALE]).GetString("GENERIC_ERROR"));

What I would like is some kind of generic method that can take in the Type of Service to get, and then return a reference to that service, without any need to cast or use enums by the callers. I know of the existence of <T> Generics, but I've never created something with them and I'm unsure of a good way to store my services and then return them directly.

I am on a C# .NET MVC project, and have a form that can dynamically add/remove n number of complex objects in a list. This complex object, for example represents a Person. This person has FirstName and Address properties.

When the user loads the page, all the People in the system are displayed in a list. When the user presses the 'add' button, two new text boxes show up for the Person's FirstName and Address properties. When the user presses the submit button, it will make a POST request to the server.

I know that you can write regular html in the View, and can use Javascript to add the new DOM elements for the FirstName and Address properties.

And with regards to when the user submits, I can use javascript to scrape all the data in the screen, and send a POST request to the server. Theoretically, another method is instead of using javascript, just make the button submit the form to the POST action of the controller; if I give my DOM elements the proper name attribute, the Action should recognize the data.

However, is there a MVC way of doing this? Maybe, with the help of Razor Helpers?

Let me describe the scenario

It is suppose to be intranet site

I have created in mvc web application which i have hosted on some server. The site gives a login page when you enter your credentials they are used to get data from an xml file on server. If you do not have access to the server it you are not able to login

After login there is page which displays details from that file and run cmd When i searched i found that user has to give some permissions iis does not run cmd on user machine. My main motive is for user to run a command in cmd. I don't want user to open cmd and run it. Due to which i have given the link in site to run cmd

I have tried some of the solutions on following links When i try this it works on local machine but not when i publish on some server and This gives permission issue when run on IE browser and on other browsers it does not work

Is there any alternate way to run the cmd because may be 1 user can give the permission but not hundreds

I want to create a pdf file using itext in spring mvc maven.but in pdf the vaules are coming into database so i dont no the flow of spring mvc i only created a jsp file and i call that values into controller. so can you tell me the actual flow of spring mvc?

Hello guys I'm a newbie in PHP and have an assignment due in the afternoon. Actually i have to create a store that use a session array to retrieve data input in a form, and display it . But the shopping cart has to be built with MVC. So here is a little details of the assignement: in the first place we have only a navbar that appears where there is two link ( both are dropdowns menu): Order and Product When you click on ORDER the dropdown menu appears and you can read "Create" and "List" . When you click on PRODUCT the dropdown menu appears and you can read "Create".

When you click on " Create" from the PRODUCT 's DROPDOWN you are redirect to a new page. On this new page there is a form where you can input the reference, name, price and quantity of the product you want to add and there is a save button too. When you click on save the informations are save in a array stored in data.php. Naturally before they get stored the information input have to check if they are valid first.

When you click on " Create" from theORDER 's DROPDOWN, there is a form with two buttons that appears in the same page where you can input information about your order. And when you click on "ADD", a table appear in which you can read the order you entered . when you click on "Save", the informations are save in a array "product" stored in data.php.

When you click on " List" from the ORDER 's DROPDOWN you are redirect to a new page. On this new page there is a table where you can see the list of your order the reference, name, price and quantity of the product you want to add and there is a save button too. And in each row there is a Details button. When you click on it an other table appears where you can see the elements ordered in that day and the Total

And i need help to know how to start this MVC model in the best way possible. All help appreciated and thanks for everything.

I'm getting System.NullReferenceException Object reference not set to an instance of an object on instantiation of a model but only sometimes. My users are experiencing the error sometimes, but once they resubmit the exception does not occur. I can't figure out why the error is happening.

Here is my error log from ELMAH:

System.NullReferenceException: Object reference not set to an instance of an object.


at Plus.Controllers.Review.ReviewNoteController.Save(ReviewNoteViewModel viewModel) in C:\Users\Rhys\Documents\Development\witplus-master\Plus\Controllers\Review\ReviewNoteController.cs:line 139
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.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)

Here is my code:

// Update Note
                if (viewModel.ID != 0)
                {
                    ReviewNote rn = _repository.Get<ReviewNote>(viewModel.ID);
                    MapViewModelToModel(rn, viewModel);
                    _repository.Update<ReviewNote>(rn);
                }
                // Create Note
                else
                {
                    ReviewAnswer ra = _repository.Get<ReviewAnswer>(viewModel.AnswerId);
                    bool newAnswer = false;
                    // Check if practice or checklists
                    if (viewModel.Referrer == Referrer.ReviewPractice)
                    {
                        // Create a new answer if it hasn't been answered yet. Could have made a bool in the GET method, but it's best to recheck to make sure no-one has answered in the mean time.
                        if (hasNoAnswer_PracticeLevel(viewModel.QuestionId))
                        {
                            ra = new ReviewAnswer();
                            ra.entityLevelAudit = true;
                            ra.entityId = this.LoggedInEntity.EntityId;
                            ra.questionId = viewModel.QuestionId;
                            ra.lastUpdateDate = DateTime.Now;
                            _repository.Save<ReviewAnswer>(ra);
                            newAnswer = true;
                            viewModel.AnswerId = ra.Id;
                        }
                    }
                    else
                    {
                        // Create a new answer if it hasn't been answered yet.
                        if (hasNoAnswer_Checklist(viewModel.QuestionId))
                        {
                            ra = new ReviewAnswer();
                            ra.entityLevelAudit = false;
                            ra.entityId = this.LoggedInEntity.EntityId;
                            ra.questionId = viewModel.QuestionId;
                            ra.userId = this.SelectedUser.UserId;
                            ra.lastUpdateDate = DateTime.Now;
                            _repository.Save<ReviewAnswer>(ra);
                            newAnswer = true;
                            viewModel.AnswerId = ra.Id;
                        }
                    }

                    ReviewNote rn = new ReviewNote();
                    rn.auditID = ra.Id;
                    rn.Type = (int)this.LoggedInUser.ReviewTypeId; //Audit Note type is the user audit type
                    MapViewModelToModel(rn, viewModel);
                    _repository.Save<ReviewNote>(rn);
                }

The error is occuring at line 139 which is:

ReviewNote rn = new ReviewNote(); // 6th last line.

The ReviewNote Model code is:

using Plus.Models.UserModel;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Web;
using System.Web.Mvc;

namespace Plus.Models.Review
{
    public class ReviewNote : BaseModel
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity), Column("AuditNoteId")]
        public int ID { get; set; } // AuditNoteId

        public int auditID { get; set; }
        [ForeignKey("auditID")]
        public virtual ReviewAnswer Answer { get; set; }

        [StringLength(10000), AllowHtml, Column("noteText")]
        public string Text { get; set; } //noteText

        [StringLength(200), Column("noteFile")]
        public string URL { get; set; } //noteFile

        [DataType(DataType.DateTime), Column("lastUpdateDate")]
        public DateTime LastUpdated { get; set; }//lastUpdateDate

        [Column("showNoteToAll")]
        public bool VisibleToAll { get; set; } //ShowNoteToAll

        [Required]
        public int NoteBy { get; set; } //NoteBy
        [ForeignKey("NoteBy")]
        public virtual User By { get; set; }

        [Column("noteType")]
        public int Type { get; set; } //NoteType
    }
}

Here is the BaseModel code:

public abstract class BaseModel
    {
        [NotMapped, JsonIgnore]
        public Alias Alias { get; set; }

        [NotMapped, JsonIgnore]
        public IDictionary<string, object> AliasDictionary { get; set; }

        [NotMapped, JsonIgnore]
        public AppUserDTO LoggedInAppUser { get; set; }

        [NotMapped, JsonIgnore]
        public UserDTO LoggedInUser { get; set; }

        [NotMapped, JsonIgnore]
        public EntityDTO LoggedInEntity { get; set; }

        [NotMapped, JsonIgnore]
        public ResourceDTO LoggedInUsersResource { get; set; }

        [NotMapped, JsonIgnore]
        public virtual ICollection<MenuItemClaim> MenuSystemTreeClaims { get; set; }

        [NotMapped, JsonIgnore]
        public IStateProvider UserSession { get; set; }

        [NotMapped, JsonIgnore]
        public UserDTO SelectedUser { get; set; }

        [NotMapped, JsonIgnore]
        public TermsAndConditions TAC { get; set; }

        [NotMapped, JsonIgnore]
        public string PageClaimValue { get; set; }
    }

I can't see why there would be an NullReferenceException on the instantiation of ReviewNote at all. If anyone could offer a suggestion it would be most helpful because it's becoming more and more of an issue for my users.

My project is ASP.NET MVC5 with Identity 2 and Entity Framework 6.2. I'm thinking the error only started after I upgraded Entity Framework 6.1 to 6.2, but it's just a guess.

Thanks.

I am using MVC for developing my UI, my UI has a dropdownlist, my UI code is

@Html.DropDownListFor(m => m.FirmInfo.PolicyInfo.MaximumSchedule, Model.FirmInfo.PolicyInfo.MaximumScheduleList, "Select", new { @class = "form-control pull-left field-line-textbox", @id = "ddlMaximumSchedule" })

In the above code i have provided my dropdown list with a default value as "select" but my issue is, when I load the UI the default value is not selected. There is another scenario in my case,

m.FirmInfo.PolicyInfo.MaximumSchedule this variable is already having a value when i load the page,so that's the reason , when i load the page m.FirmInfo.PolicyInfo.MaximumScheduleheresince this variable is having a value in it, automatically that is getting selected, But i want select as a default value. How can I achieve this, Help me out. Thanks in Advance.

I've been working on dropdown menu on ASP.NET Master Page. I've implemented it and it shows on the webpage view, but it's not dropping down. Can't find the solution, any ideas?

MasterPage

The View on Webpage

Im trying to implement this way of populating a gridview https://aspdotnetcodebook.blogspot.com.ar/2008/07/using-arraylist-as-datasource-for.html but separating the objects. I made 1 proyect (ASP.NET Empty Web Form) and 1 proyect (Class Library). Class library has got: Person.cs and PersonList.cs

[Serializable()]
class Person
{
    public string name { get; set; }
    public string surname { get; set; }
}

class PersonList
{
    List<GrillaEquipo> GrillaEquipoLista = new List<GrillaEquipo>();

    public List<GrillaEquipo> ListaEquipo
    {
        get
        {
            if (HttpContext.Current.Session["GrillaEquipoLista"] == null)
            {
                HttpContext.Current.Session["GrillaEquipoLista"] = new List<GrillaEquipo>();
            }
            return HttpContext.Current.Session["GrillaEquipoLista"] as List<GrillaEquipo>;
        }
    }
}

In the ASP.NET proyect, Default.ascx.cs

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
          //How to populate?
        }
    }

    protected void BtnArgegar_Click(object sender, EventArgs e)
    {
        Person per = new Person();
        Equipo.name = "Prueba";
        Equipo.surname = "Prueba2";

        //call the list/session again and add the new item
        //bind it to the gridview
    }

The idea is to populate a gridview using a List passed to a Session Object and also be able to add items to the list and bind the new datasource.

my project is fine when I run my application in localhost. however, i found this error when I run this on server.

I am working with a ListView with multiple items listed, each with their own buy button. Right now the user can select the buy button on the item (car) they want, and it takes them to the BuyCars.aspx page, but nothing shows up for the selected item (car). I'm having trouble figuring out how to send the data when the user clicks buy on a certain car to the BuyCars.aspx total page.

I apologize for the amount of code, but this issue is driving me insane.

Here is my code. Thank you!

Cars.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterBlaster024.Master" AutoEventWireup="True" CodeBehind="Cars.aspx.cs" Inherits="CarSales_REAL.WebForm2" %>
  <asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server">
  </asp:Content>
  <asp:Content ID="Content2" ContentPlaceHolderID="div2" runat="server">
    <div class="row">
      <asp:ListView ID="ListView1" runat="server" class="custom-class" DataSourceID="SqlDataSource1" OnItemCommand="ListView1_ItemCommand" DataKeyNames="CarID" OnSelectedIndexChanged="ListView1_SelectedIndexChanged">
        <ItemTemplate>
          <div class="col-sm-4">
            <div class="custom_class">
              <a href='/Shop/Order/<%# Eval("CarID") %>'>
                            <img src='/Images/<%# Eval("ImageCar") %>'
                                alt='<%# Eval("Name") %>' /></a>
              <div class="caption">
                <h3>
                  <%# Eval("Name") %>
                </h3>
                <p><b>Price: <%# Eval("CarPrice", "{0:c}") %></b>
                  <br><br>
                  <%# Eval("Long_Description") %>
                </p>
              </div>
              <%--<div class="row">
                            <div class ="form-group">
                                <label class="col-sm-1">Quantity:</label>
                            </div>     
                                                                               
                        </div>--%>
                <div class="col-sm-8">
                  <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator1" CssClass="text-danger"
                            runat="server" ControlToValidate="txtQuantity1" Display="Dynamic" 
                            ErrorMessage="Quantity is a required field." ValidationGroup='<%# ListView1.ClientID + "_" + Container.DataItemIndex %>'></asp:RequiredFieldValidator>
                    <asp:RangeValidator ID="RangeValidator1" runat="server" CssClass="text-danger" ControlToValidate="txtQuantity1" Display="Dynamic" ErrorMessage="Quantity must range from 1 to 2." MaximumValue="2" MinimumValue="1" Type="Integer"></asp:RangeValidator>--%>

                </div>
                <div class="form-group">
                  <div class="col-sm-12">
                    <div class="col-sm-12">
                      <asp:Button ID="btnBuy" runat="server" Text="Buy Car" onclick="btnAdd_Click" CssClass="btn" ValidationGroup='<%# ListView1.ClientID + "_" + Container.DataItemIndex %>' />
                      <asp:Button ID="btnCart" runat="server" Text="See Selected Car" PostBackUrl="~/BuyCars.aspx" CausesValidation="False" CssClass="btn" />


                    </div>
                  </div>
                </div>
                <div>
                  <asp:Label ID="lblMessage" runat="server" EnableViewState="false" CssClass="text-info col-sm-12"></asp:Label>
                </div>
            </div>

          </div>
        </ItemTemplate>
      </asp:ListView>
      <%--<div class="col-sm-3">
                                <asp:TextBox ID="txtQuantity1" runat="server"                
                                CssClass="form-control"></asp:TextBox>
                            </div>--%>
    </div>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [CarID], [Name], [Long_Description], [CarPrice], [ImageCar] FROM [Table] ORDER BY [Name]" OnSelecting="SqlDataSource1_Selecting"></asp:SqlDataSource>
  </asp:Content>

Cars.aspx.cs

namespace CarSales_REAL
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        private Product selectedProduct;

        

        protected void Page_Load(object sender, EventArgs e)
        {
            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            
            if (!IsPostBack) ListView1.DataBind();
            selectedProduct = this.GetSelectedProduct();
            

        }

        private Product GetSelectedProduct()
        {
            DataView productsTable = (DataView)
                SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            //productsTable.RowFilter = "CarID = '" + ListView1.SelectedValue + "'";
            DataRowView row = productsTable[1];

            Product p = new Product();
            p.CardID = row["CarID"].ToString();
            p.Name = row["Name"].ToString();
            //p.Short_Description = row["Short_Description"].ToString();
            p.Long_description = row["long_Description"].ToString();
            p.CarPrice = (decimal)row["CarPrice"];
            //p.ImageFile = row["ImageFile"].ToString();
            return p;
        }

        protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
            
           
            
            
        }

        

        protected void btnAdd_Click(object sender, EventArgs e)

        {
            Button btnBuy = (Button)sender;
            if (Page.IsValid)
            {
                CartItemList cart = CartItemList.GetCart();
                CartItem cartItem = cart[selectedProduct.CardID];

                if (cartItem == null)
                {
                    //cart.AddItem(selectedProduct,
                    //                Convert.ToInt32(txtQuantity1.Text));
                }
                else
                {
                    //cartItem.AddQuantity(Convert.ToInt32(txtQuantity1.Text));
                }
                Response.Redirect("BuyCars.aspx");

            }
        }

        protected void btnCart_Click(object sender, EventArgs e)
        {
            
        }

        protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
        {

        }
    }
}

BuyCars.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterBlaster024.Master" AutoEventWireup="True" CodeBehind="BuyCars.aspx.cs" Inherits="CarSales_REAL.WebForm3" %>
<%@ MasterType VirtualPath="~/MasterBlaster024.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server">
    
</asp:Content>
    
<asp:Content ID="Content2" ContentPlaceHolderID="div2" runat="server">
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <div class="col-sm-12"><asp:ListBox ID="Cart1" runat="server" CssClass="form-control"></asp:ListBox></div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12"><asp:Button ID="btnRemove" runat="server" 
                Text="Remove Item" OnClick="btnRemove_Click" CssClass="btn"/></div>
            <div class="form-group">
                <div class="col-sm-12"><asp:Button ID="btnEmpty" runat="server"
                    Text="Empty Cart" OnClick="btnEmpty_Click" CssClass="btn" />
                </div>
            </div>
        </div>
        <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <asp:Label ID="lblMessage" runat="server" EnableViewState="false"
                    CssClass="text-info col-sm-12"></asp:Label>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <asp:Button ID="btnContinue" runat="server"
                        PostBackUrl="~/Cars.aspx" Text="Continue Shopping" CssClass="btn" />
                    <asp:Button ID="btnCheckOut" runat="server" Text="Check Out"  
                        onclick="btnCheckOut_Click" CssClass="btn" />
                </div>
            </div>

        </div>
        </div>

    
    </div>
</asp:Content>

BuyCars.aspx.cs

namespace CarSales_REAL
{
    
    
        public partial class WebForm3 : System.Web.UI.Page
        {
            private CartItemList cart;

            
            protected void Page_Load(object sender, EventArgs e)
            {
                

                cart = CartItemList.GetCart();
                if (!IsPostBack)
                    this.DisplayCart();
            }

            private void DisplayCart()
            {

                Cart1.Items.Clear();
                CartItem item;

                for (int i = 0; i < cart.Count; i++)
                {
                    item = cart[i];
                    Cart1.Items.Add(item.Display());
                }
            }

            protected void btnRemove_Click(object sender, EventArgs e)
            {
                if (cart.Count > 0)
                {
                    if (Cart1.SelectedIndex > -1)
                    

                    
                    {
                        cart.RemoveAt(Cart1.SelectedIndex);
                        this.DisplayCart();
                    }
                    else
                    {
                        lblMessage.Text = "Please select the item you want to remove.";
                    }
                }
            }

            protected void btnEmpty_Click(object sender, EventArgs e)
            {
                if (cart.Count > 0)
                {
                    cart.Clear();
                    Cart1.Items.Clear();
                }
            }

            protected void btnCheckOut_Click(object sender, EventArgs e)
            {
                lblMessage.Text = "Sorry, that function hasn't been implemented yet.";
            }
        }
    
}

Hi everyone I am new with bootstrap. I have been using a bootstrap template in my asp.net web form project. I am done with master page. Now i have been designing a content page. The content page will contain an Form like bellow image:

https://i.stack.imgur.com/5zrer.png

As I am new with bootstrap I do not know how I can do this and what CSS class should i use. Can anyone give me some sample.

My Master Page Code is given bellow:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
     <meta charset="utf-8"/>
     <%--<meta name="viewport" content="width=device-width, initial-scale=1"/>--%>
    <meta name="viewport" content="width=device-width, initial-scale = 1.0, 
maximum-scale=1.0, user-scalable=no" /> 
     <link type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <link href="Styles/main.css" type="text/css" rel="Stylesheet" />

    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style>
        /*.navbar-brand {
  display: inline-block;
  float: none;
  font-size: 18px;
  height: 100%;
  padding: 0;
  vertical-align: middle;
}*/
    </style>
</head>
<body>
      <form id="form1" runat="server">
  <%--<div class="divHdr">
      <div style="float:left;"><a href="Default.aspx"><asp:Image ID="imgLogo" 
              runat="server" Height="90" Width="250"/></a></div>  
        <div style="float:left;padding-left:300px;padding-top:3px;"><asp:Image ID="imgTop" 
                ImageUrl="~/images/top_banner/Buildexpo-ban.jpg" runat="server" Height="80" 
                Width="400"/></div>
        <div class="clearBt"></div>
    </div>--%>

<%--<div class="container">
    <nav class="navbar navbar-default">
      <div class="container-fluid">
          <div class="navbar-header">
    <div style="float:left;"><a href="Default.aspx"><asp:Image ID="imgLogo" class="img-responsive"
              runat="server" Height="90" Width="250"/></a></div>  
        <div style="float:left;padding-left:300px;padding-top:3px;"><asp:Image ID="imgTop" class="img-responsive"
                ImageUrl="~/images/top_banner/Buildexpo-ban.jpg" runat="server" Height="80" 
                Width="400"/></div>
        <div class="clearBt"></div>
              </div>
          </div></nav>
</div>--%>

   <%-- <div class="container-fluid">--%>
     <div class="wrapper">
   <%-- <nav class="navbar navbar-default">--%>
  <div class="container-fluid">

      <div class="row">
        <div class="col-sm-4">
         <%-- <div class="navbar-header">--%>


                <a href="Default.aspx"><asp:Image ID="imgLogo"  ImageUrl="~/images/logo/19.18.50-build%20Kenya.png"
              runat="server" class="img-responsive" Height="90" Width="250"/></a><%--</div> --%>
            </div>



            <div class="col-sm-6">

           <%-- <ul class="nav navbar-nav navbar-right">--%>

                <asp:Image ID="imgTop" class="img-responsive"
                ImageUrl="~/images/top_banner/19.18.21-TOP%20Kenya%20BUILD.jpg" runat="server" Height="80" 
                Width="400"/>
          <%--   </ul>--%>


            </div>
            <div class="clearfix"></div>
          </div>         
      </div> 


   <div class="dvMnCnt">
         <div class="container">

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

                 </div>
                 <div class="col-sm-6">
                      <strong>Submission Deadline :</strong>  <blink><asp:Label 
            ID="lblDeadline" runat="server" CssClass="lblDeadln" ></asp:Label></blink>&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="buttLogin" runat="server" style="font-size:15px;" Font-Bold="True" 
                             BorderStyle="None" Text="Logout" BackColor="Transparent" ForeColor="#3399FF"  onclick="buttLogin_Click" /> | 
      &nbsp; <a href="Messages_recieved.aspx"> <strong>Notifications</strong></a>(<asp:Label ID="Label2" runat="server"></asp:Label>)<asp:Image ID="Image2" runat="server"  />

                 </div>
             </div>
             <div class="row">
                 <div class="col-sm-3">

                 </div>
                 <div class="col-sm-9">
                     <p style="font-family:Calibri;color:#393838;font-size:15px;letter-spacing:1.5px;">Please fill up the forms in the left menu below to submit necessary information required by the organizers</p>
                 </div>
             </div>
               <%--  </div>--%>

       <div class="dvMnSbCnt">
           <%--<div class="container-fluid">--%>
               <div class="row">
                   <div class="col-md-4">
                        <div class="divFrmTtl">EXHIBITORS FORMS</div>
                          <div id="navtab1" runat="server" class="dvFrmLinks"><a href="exhibitor-catalog.aspx">Online Exhibitors Catalogue</a></div>
                          <div id="navtab2" runat="server" class="dvFrmLinks"><a href="exhibitor-badges.aspx">Exhibitors Badges</a></div>
                          <div id="divpass" runat="server" class="dvFrmLinks"><a href="passport_details.aspx">Exhibitors Passport<span class="brkt"> ( </span><span class="FrmLinksSpn">For Referred Visa</span><span class="brkt"> )</span></a></div>
                          <div id="divflight" runat="server" class="dvFrmLinks"><a href="Flight-details.aspx">Exhibitors Flight<span class="brkt"> ( </span><span class="FrmLinksSpn">For Package</span><span class="brkt"> )</span></a></div>
                          <div id="navtab3" runat="server" class="dvFrmLinks"><a href="payment.aspx">Payment Status</a></div>
                          <div id="navtab4" runat="server" class="dvFrmLinks"><a href="Media-info.aspx">Media Info/Press Release</a></div>
                   </div>
                   <div class="col-md-4">
                       <div class="divExFrmTtl">EXHIBITORS INFORMATION</div>
                        <div class="dvFrmLinks"><asp:HyperLink id="HyperLink1" runat="server" Target="_blank">Exhibition Kit</asp:HyperLink></div>
                        <div class="dvFrmLinks"><a href="http://www.expogr.com/exhibitingtips.htm"  target="_blank">Exhibitor Tips</a></div>
                        <div class="dvFrmLinks"><asp:HyperLink runat="server" ID="HyperLink2" target="_blank" >Frequently Asked Questions</asp:HyperLink></div>

                        <div class="dvFrmLinks"> <asp:HyperLink runat="server" ID="HyperLink3"  target="_blank" >Exhibitor Information Manual</asp:HyperLink>
                        </div>
                   </div>
                   <div class="col-md-4">
                       <div class="divCntryFrmTtl">COUNTRY INFORMATION</div>
                        <div class="dvFrmLinks"><asp:HyperLink runat="server" ID="hperCountryInfo"  target="_blank">Country Information</asp:HyperLink></div>
                       <div class="dvFrmLinks"><asp:HyperLink runat="server" target="_blank" NavigateUrl="https://embassy.goabroad.com/embassies-in/rwanda" ID="hperEmbasses">Embassies</asp:HyperLink></div>
                       <div class="dvFrmLinks"><asp:HyperLink runat="server" ID="hperNews" target="_blank">Market News</asp:HyperLink></div>
                       <div class="dvFrmLinks"><asp:HyperLink runat="server" ID="hperVisaInfo" target="_blank">Visa Information</asp:HyperLink></div>
                   </div>
               </div>
              <div class="clearfix"></div>
         <%--  </div>--%>
       </div>



             </div>

         <div class="clearfix"></div>
         </div>


       <%--<div class="container-fluid">
        <div class="row-fluid">
        <div class="dvMnCnt">
     <div style="margin:auto;color:#393838;width:960px;font-size:15px;padding-top:13px;font-family:Calibri;font-weight:bold; text-align:right;padding-right:30px;">Submission Deadline :  <blink><asp:Label 
            ID="lblDeadline" runat="server" CssClass="lblDeadln" ></asp:Label></blink>&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="buttLogin" runat="server" style="font-size:15px;" Font-Bold="True" 
                             BorderStyle="None" Text="Logout" BackColor="Transparent" ForeColor="#3399FF"  onclick="buttLogin_Click" /> | 
      &nbsp; <a href="Messages_recieved.aspx"> Notifications</a>(<asp:Label ID="lblnotification" runat="server"></asp:Label>)<asp:Image ID="Image1" runat="server"  />
        </div>
    <div align="center" style="margin:auto;color:#393838;width:960px;font-size:15px;padding-top:20px;letter-spacing:1.5px;font-family:Calibri;">Please fill up the forms in the left menu below to submit necessary information required by the organizers</div>




    <div class="clearBt"></div>

  </div>
  </div>
  </div>--%>

<%--</nav>--%>


          <div style="padding-top:10px;background-color:#fcfcfc;">
            <div class="container">

    <%--<div style="width:960px;margin:auto;margin-top:20px;margin-bottom:30px;padding-bottom:15px;">--%>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>


         <asp:Panel ID="pnlBen" runat="server">

        <div class="row">

           <%-- <div class="col-md-6" style="margin-left:100px;margin-top:10px;margin-bottom:30px;padding-bottom:15px;">     --%>    

            <div class="col-md-12" style="margin-left:90px;padding-bottom:15px;margin-bottom:30px;">                    
                      <asp:Image runat="server" ImageUrl="~/images/benefits/19.18.17-bottom%20banner%20-%20Build.jpg" ID="imgInterestedIN" CssClass="img-responsive"/> 
               <%--   <div class="row"><div class="col-md-12">--%>
                       <div  id="dvtwoevent" style="width:960px;padding-top:13px;padding-left:32px;background-color:#eaeaea;padding-bottom:5px;">
         <table class="table-responsive" width="100%">
         <tr><td valign="top" > <asp:RadioButtonList ID="rdoInterested" Font-Size="13px"  CssClass="radio"  
                 runat="server" AutoPostBack="True" 

                 RepeatDirection="Horizontal">
             <asp:ListItem>Yes,I am Interested in Both Events. Please Send me More Information</asp:ListItem>
             <asp:ListItem >Sorry , Not Interested</asp:ListItem>  
             </asp:RadioButtonList></td><td style="padding-left:45px;"><asp:Button ID="buttnSend" runat="server" CssClass="dvSend" ToolTip="Please Select Option" ForeColor="White" BackColor="#fd0200" Text="Send" Width="70px"
                 Enabled="False" /></td></tr></table>

             </div><%--</div></div>--%>
                   </div>                             
              <div class="clearfix"></div>


            </div>

            </asp:Panel>
            </div>





          <%--  <div class="col-md-2"></div>--%>


       </div>






       <%--   <asp:Panel ID="pnlBen" runat="server">
         <asp:Image runat="server" ImageUrl="~/images/benefits/19.18.17-bottom%20banner%20-%20Build.jpg" ID="imgInterestedIN" CssClass="img-responsive" />   
         <div  id="dvtwoevent" style="padding-top:13px;padding-left:32px;background-color:#eaeaea;padding-bottom:5px;">
         <table>
         <tr><td valign="top" > <asp:RadioButtonList ID="rdoInterested" Font-Size="13px"  CssClass="rdobuttn"  
                 runat="server" AutoPostBack="True"                
                 RepeatDirection="Horizontal">
             <asp:ListItem>Yes,I am Interested in Both Events. Please Send me More Information</asp:ListItem>
             <asp:ListItem >Sorry , Not Interested</asp:ListItem>  
             </asp:RadioButtonList></td><td style="padding-left:45px;"><asp:Button ID="buttnSend" runat="server" CssClass="dvSend" ToolTip="Please Select Option" ForeColor="White" BackColor="#fd0200" Text="Send" Width="70px"
                  Enabled="False" /></td></tr></table>


                  </asp:Panel>--%>


         <%-- <div style="padding-top:7px;">

          </div>
            --%>

             <%-- </div>--%>



       <%--  <footer class="container-fluid text-center">
           <div class="dvCpyrght">
        <div class="copyright">© Copyright 2014 - Expogroup <span style="padding-left:710px;">    </span></div>
        </div>
             </footer>--%>

             <div class="dvCpyrght">
     <div class="copyright">© Copyright 2014 - Expogroup <span style="padding-left:710px;">    </span></div>
                 </div>







</div>
</form>
</body>
</html>

Following is .cshtml code:

using (Ajax.BeginForm("UploadEdit", "Widget", new { Type = "SampleSurvey" }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "SampleSurvey-widget", LoadingElementId = "report-loader", OnBegin = "$('#report-loader').show();", OnSuccess = "$('#report-loader').hide();" }, new { enctype = "multipart/form-data", id = "SampleSurvey" }))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(model => model.Type)
    @Html.HiddenFor(model => model.IsDealer)
    @Html.HiddenFor(model => model.Filter)

    <div class="form form--searchcriteria">
        <fieldset class="">
            <div class="field_group">
                <div class="field">
                    @Html.LabelFor(Model => Model.FirstName, new { @class = "field__label" })
                    <div class="field__controls">
                        @Html.EditorFor(model => model.FirstName)
                        @Html.ValidationMessageFor(model => model.FirstName)
                    </div>
                </div>
                <div class="field">
                    @Html.LabelFor(model => model.LastName, new { @class = "field__label" })
                    <div class="field__controls">
                        @Html.EditorFor(model => model.LastName)
                        @Html.ValidationMessageFor(model => model.LastName)
                    </div>
                </div>
                <div class="field">
                    @Html.LabelFor(model => model.Email, new { @class = "field__label" })
                    <div class="field__controls">
                        @Html.EditorFor(model => model.Email)
                        @Html.ValidationMessageFor(model => model.Email)
                    </div>
                </div>
            </div>
        </fieldset>         
        <div class="form-control">
            <button id="btnSubmit" class="btn icon icon-location-arrow" type="submit" onclick="$('#report-loader').show();">Send invitation</button>
        </div>

    </div>
}

And following is my model:

public class SampleSurvey : WidgetBase
{      
    [Required]
    [StringLength(100, ErrorMessage = "Maximum 100 characters are allowed in field")]
    [Display(Name = "First Name")]
    public string FirstName { get; set; }

    [Required]
    [StringLength(100, ErrorMessage = "Maximum 100 characters are allowed in field")]
    [Display(Name = "Last Name")]
    public string LastName { get; set; }

    [Required]
    [DataType(DataType.EmailAddress, ErrorMessage = "Invalid field.")]
    [Display(Name = "Email Address")]
    public string Email { get; set; }      

}

But still validation is not working upon clicking the submit button, help will highly be appreciated.

I am trying to add an asp.net image control () in a panel at runtime.

I have the asp.net code in the label text as <asp:Image runat="server" ImageUrl="test.png"/> (its just a example)

When I added this label in the panel control with: pnlPlaceHolderPanel.Controls.Add(htmlLabel);

The image does not display. When I checked the HTML using inspect element in the browser, the element displayed in <asp:Image>, but it should be <img> tag of HTML.

So does anybody know how should I convert that asp.net design code into HTML code?