How to implement a concept in Web Application where in i have the flow from one of my version say classic to a newer version we have hosted. For example in gmail(Regular to Html version) or SharePoint(between different versions) And also what key points to take care while doing the same.

//Code to fetch the booking history and their addresses from the database
List<AssessmentBooking> assessmentHistory = dbContext.Database
                     .SqlQuery<AssessmentBooking>("EXEC [InsuredTech].[dbo].[GetAssessmentBookingHistory] @p_CLM_ID", parameters)

//Booking model
public class AssessmentBooking
    public int ID { get; set; }

    public int CLM_ID { get; set; }

    public string AssessmentArea { get; set; }

    public string AssessmentType { get; set; }

    public bool Internal { get; set; }

    public int? AssessorID { get; set; }

    public Address Address { get; set; }

    public string VehicleRegistrationNumber { get; set; }

    public DateTime? AssessmentDate { get; set; }

    public TimeSpan? AssessmentStartTime { get; set; }

    public TimeSpan? AssessmentEndTime { get; set; }

    public string BookingStatus { get; set; }

    public string Instructions { get; set; }

    public string CreatedUser { get; set; }

    public DateTime CreatedDate { get; set; }

    public string LastupdatedUser { get; set; }

    public DateTime LastupdatedDate { get; set; }

//Address Model

public class Address
    public string FullAddress { get; set; }

    public string Unit { get; set; }

    public string Level { get; set; }      

    public string HouseNumber { get; set; }

    public string StreetNumber { get; set; }

    public string StreetName { get; set; }

    public string Suburb { get; set; }

    public string PostCode { get; set; }

    public string State { get; set; }

    public string Country { get; set; }

Stored procedure:

CREATE PROCEDURE [dbo].[GetAssessmentBookingHistory]
@p_CLM_ID int
SELECT ID, CLM_ID, AssessmentArea, AssessmentType, Internal, AssessmentDate, LOV.Value AS BookingStatus, AssessmentStartTime,AssessmentEndTime, AssessmentAddress As [FullAddress], Unit, [Level], HouseNumber, StreetNumber, StreetName, PostCode, Suburb, [State], Country, VehicleRegNumber, Instructions FROM AssessmentBooking AB
ON LOV.[Text] = AB.AllocationStatusID 

I want to make file after upload get name ID + "NameFile"

this for my controller

   public ActionResult Index (updown viewModel, HttpPostedFileBase file)
         string file_1 = System.IO.Path.GetFileName(file.FileName);
         string path = System.IO.Path.Combine(Server.MapPath("~/App_Data/upload"), + file_1);

         return View(viewModel);

I am working with ASP.NET MVC APIs and I am trying to do is create login / logout system without credentials, this is what I have so far:

Database table of users, this table has a varchar(MAX) column called email, bool column called online, a varchar(MAX) called token, a DateTime column called tokenDate

I get the user by their email

public IQueryable<CheckInClass> GetEmail(string email)
            return db.Data.Where(model => == email).AsQueryable();

When they goto the page, first I check if the user is marked online, I am also currently using cookies, so I check if a cookie exists

        public void MarkOnline(string offline)
            BookingLCPreview existing = db.Data.FirstOrDefault(u => == offline);
            existing.isOnline = true;

        public void CreateCookie(string create)
            HttpCookie myCookie = new HttpCookie("user" + create);
            myCookie.Value = create;
            myCookie.Expires = DateTime.Now.AddHours(2);

If they not online and the cookie doesn’t exist, they marked as online, and currently I am creating a cookie

        public bool CheckCookie(string check)
            if (HttpContext.Current.Request.Cookies["user" + check] != null)
                if (HttpContext.Current.Request.Cookies["user" + check].Value == check)
                    return true;
                    return false;
                return false;

If they are online and cookie doesn’t exist, they are not allowed to enter the page. What I am trying to do is when the user goes to the page, get their email, mark them as online and prevent other users to goto the page with the same email, now my question is, with the tools and columns I have available to me, what would be the best way to do this? The way I did it, does the trick I guess, but don’t feel good about it.

There is a logout button that deletes the cookie and marks the user as offline.

        public void RemoveCookie(string remove)
            if (HttpContext.Current.Request.Cookies["user" + remove] != null)
                HttpCookie myCookie = new HttpCookie("user" + remove);
                myCookie.Expires = DateTime.Now.AddDays(-1d);

        public void MarkOffline(string online)
            BookingLCPreview existing = db.Data.FirstOrDefault(u => == online);
            existing.isOnline = false;

I am using c# MVC for my project, and my project has the default configuration for registering users and login.

I added a new role

 public async Task<ActionResult> Register(RegisterViewModel model)
        if (ModelState.IsValid)
            var user = new ApplicationUser { UserName = model.Email
                , Email = model.Email
            var result = await UserManager.CreateAsync(user, model.Password);
            if (result.Succeeded)
                //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                // await UserManager.SendEmailAsync(user.Id, "Confirmar cuenta", "Para confirmar la cuenta, haga clic <a href=\"" + callbackUrl + "\">aquí</a>");

                //temp code 
                var roleStore = new RoleStore<IdentityRole>(new ApplicationDbContext());
                var roleManager = new RoleManager<IdentityRole>(roleStore);
                await roleManager.CreateAsync(new IdentityRole("IsStudent"));
                await UserManager.AddToRoleAsync(user.Id, "IsStudent");

                await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                return RedirectToAction("Index", "Home");

In my database, I register the new user, but when I log out and try to login again I receive the following error:

The model item passed into the dictionary is of type 'project.Models.LoginViewModel', but this dictionary requires a model item of type 'project.Models.RoleName'

this error appears just with the new role, but with other roles it did not appear. What can be happening? how can I fix it?

I'm having a hard time in returning the formatted JSON as an array. My current code already returns JSON as an array but I want to get rid of these bracket first [] to get my desired output.


public JsonResult GenerateGanttChart()
        SPMS_GanttChartLayers ddl = new SPMS_GanttChartLayers();
        var data = ddl.GenerateGanttChart();
        return Json(data, JsonRequestBehavior.AllowGet);


public IEnumerable<SPMS_GanttChartRootModel> GenerateGanttChart()
        List<SPMS_GanttChartModel> child_data = new List<SPMS_GanttChartModel>();
            using (SqlConnection con = new SqlConnection(Conn.MyConn()))
                SqlCommand com = new SqlCommand("dbo.sp_SPMS_GanttChart 7078, 1", con);
                SqlDataReader reader = com.ExecuteReader();
                while (reader.Read())
                    SPMS_GanttChartModel value = new SPMS_GanttChartModel();
           = Convert.ToInt32(reader.GetValue(0));
                    value.start_date = Convert.ToString(reader.GetValue(1));
                    value.duration = Convert.ToInt32(reader.GetValue(2));
                    value.text = Convert.ToString(reader.GetValue(3));

        List<SPMS_GanttChartRootModel> array = new List<SPMS_GanttChartRootModel>();
            SPMS_GanttChartRootModel value = new SPMS_GanttChartRootModel();
   = child_data;
        return array;

Current Output

"data": [{
    "id": 1,
    "start_date": "11/07/2017 08:00:00 AM",
    "duration": 23,
    "text": "Project #1"
}, ... ]

Desired Output

"data": [{
    "id": 1,
    "start_date": "11/07/2017 08:00:00 AM",
    "duration": 23,
    "text": "Project #1"
}, ... ]

I was following along with the Codeigniter tutorial ( and was having an issue with the news items form to add data to my database. I was able to set up the form, but when I submit any information, the connection times out and I get This site can’t be reached.

I think the action for my form is incorrect, but I have been following along with tutorial so can't be sure. Could it be an issue with the database connection or something else?

The code for the form is:

<h2><?php echo $title; ?></h2>

<?php echo validation_errors(); ?>

<?php echo form_open('news/create'); ?>

<label for="title">Title</label>
<input type="input" name="title" /><br />

<label for="text">Text</label>
<textarea name="text"></textarea><br />

<input type="submit" name="submit" value="Create news item" />


I have a jQuery datatable with paginated data. The table textbox fields are binded to the View model using Razor TextBoxFor syntax. However when I submit the form only the current page data is saved to the backend. All other data is lost.

I think only the current page exists in the DOM therefore only that data gets sent to the backend. How can I keep all data in the DOM for submitting?

I tried stateSave: true but it did not work...

enter image description here

When I create a new ASP.NET Core Web API application with the Web API template and run it in the console I do not get the following line:

info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\myname\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.

However, after upgrading an existing ASP.NET Core Web Api project to ASP.NET Core 2.0 I am receiving this info message at the top of the console when running my Web API.

Does anyone know what setting could be in my application that is causing this info message to appear? I have been trying to comment lines in the Startup.cs out and re-run the API and the message still shows.

I want to create an a site close to AirBnB but a little bit different using ASP.NET. But i do not know which is the best type of database to use. i need a way of storing the uploaded images and retrieving them in a fast and efficient way to minimize latency.

How do sites like Instagram and amazon store their images. which kind of database do they used. and how are the images accessed later on.

Thanks in advance.

Need access model constant in blade not with full path

class PaymentMethod extends Model {

const PAYPAL_ACCOUNT      = 'paypal_account';
const CREDIT_CARD         = 'credit_card';

and in blade

        {{ App\Classes\Models\PaymentMethod::CREDIT_CARD }}



        {{ PaymentMethod::CREDIT_CARD }}

throws Class 'PaymentMethod' not found

I'm building a simple app for entertainment with ASP.NET Core where I currently just have a Post model and a User model.


using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace WebApplication1.Models
    public class Post
        public int Id { get; set; }

        public string Title { get; set; }

        public string Body { get; set; }

        public Person Author { get; set; }


using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace WebApplication1.Models
    public class Person
        public int Id { get; set; }

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string Email { get; set; }

        public string Password { get; set; }

        public ICollection<Post> Posts = new List<Post>();

I used Visual Studio's scaffolding to generate controllers for those models. When I'm trying to POST /api/posts in order to create a new post, I want also to specify the Author ID for that post.

I tried adding the attribute authorId, I tried "authorId": 1 and also "author": { "id": 1 }, but because the Author is required, I always get back either Author is missing or Email in author is missing etc.

How can I include the authorId for in the post body in order I would be able to successfully create a new post?

I have got a Textbox accepting mobile number. How do I add default (Default to browser country) country code before the mobile number?

I am using MVC ASP.NET

I have a datatable with Edit,Delete actionlinks in each row. Instead of showing them as a column in the table, I would like to show them in a tooltip to save space. I am not sure how this can be achieved. I would like the tooltip to appear on the @rowNo.ToString("000") field. Thanks for the help. My code is as follows:

            @foreach (var item in Model)

                        @Html.ActionLink("Edit", "Edit", new { id = item.Id }) 
| @Html.ActionLink("Delete", "Delete", new { id = item.Id })

What I'm trying to do is, when I click on the button it should show an alert box. Here is the code.

protected void btnAdd_Click(object sender, EventArgs e)
    string script = "<script type=\"text/javascript\">alert('abc 1');
    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert 1", 


It is working perfectly but when I put this same code in another page it does not work.

what are the things I have to look into? any suggestion please?

I am a beginner in video streaming and handling.

I need to take the stream from a Basler GiGE camera and display it in a web container.

I am using the Basler.Pylon C# API to access the camera and grab images one by one. from the IGrabResult object returned, I can access various parameters such as width, height, stride, and of course the byte buffer.

On my PC, I can easily display that in an image window, but what do i need to do to display that in an ASP.NET web application?


I am not looking for code but more for guidelines, if someone could explain how video streaming works in general, that would work too

Why does all responses from ASP.NET contain Cache-Control: private? Even a 404 response? Is there something in IIS that sets this default value, and is there a way to configure it? Or is there something in ASP.NET that sets this?

For dynamic content (that is, all MVC results) I would not like it to be cached by the browser, since it is dynamic and can change at any time. Static content is hosted on a CDN, so is not served by IIS.


To clarify, I understand very well what Cache-Control: private is, the difference between private, public, no-store, etc and how/when to use them. The question I have is why Cache-Control: private is added by default by IIS/ASP.NET and how to prevent it from being added by default. I understand that it can be useful to cache dynamic pages, but in my application I don't want to cache dynamic pages/responses. For example, I don't want XHR JSON responses to be cached, since they contain dynamic content. Unfortunately the server adds Cache-Control: private to all responses automatically, so I have to manually override it everywhere.

How to reproduce: Open visual studio and create a new ASP.NET Framework (yes, framework, no not Core. We are not able to migrate our system to core yet) solution with an MVC project. Now start the project in IIS Express (just press the play button), and use F12 devtools in the browser to look at the http response. You will see that it contains Cache-Control: private. My question is, what adds this header, and how can I prevent it from being added by default?

enter image description here

I am trying to paint bars in an char instead of this way: enter image description here this other way: enter image description here

I mean, I would like to paint the bar starting in the point 1 and displaced 55px to the right.

I have achieved this: enter image description here

with the following code:


    int[,] horas = new int[,] { { 0, 1 }, { 1, 1 }, { 2, 0 }, { 3, 1 }, { 4, 0 }, { 5, 1 }, { 6, 0 }, { 7, 0 }, { 8, 1 }, { 9, 1 } };
    Chart1.DataSource = horas;
    var series1 = new Series
        Color = System.Drawing.Color.Green,
        IsVisibleInLegend = false,
        IsXValueIndexed = true,
        ChartType = SeriesChartType.RangeColumn,
    series1["PixelPointWidth"] = "1";

    int[,] horas1 = new int[,] { { 0, 1 }, { 1, 1 }, { 2, 0 }, { 3, 1 }, { 4, 0 }, { 5, 1 }, { 6, 0 }, { 7, 0 }, { 8, 1 }, { 9, 1 } };
    var series2 = new Series
        Color = System.Drawing.Color.Green,
        IsVisibleInLegend = false,
        IsXValueIndexed = true,
        ChartType = SeriesChartType.RangeColumn
    series2["PixelPointWidth"] = "110";

    for (int i = 0; i < horas.GetLength(0); i++)
        series1.Points.AddXY(horas[i, 0], horas[i, 1]);
    for (int i = 0; i < horas.GetLength(0); i++)
        series2.Points.AddXY(horas1[i, 0], horas1[i, 1]);

    int b = 0;
    foreach (var label in Chart1.ChartAreas[0].AxisX.CustomLabels)
        label.Text = b.ToString();


    Chart1.ChartAreas[0].AxisY.Interval = 0;
    Chart1.ChartAreas[0].AxisX.Interval = 1;
    Chart1.ChartAreas[0].AxisY.Maximum = 1;
    Chart1.ChartAreas[0].AxisY.Minimum = 0;

    Chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
    Chart1.ChartAreas[0].AxisY.MajorGrid.LineWidth = 0;

But this is not an optimal solution as I must paint at least 1 pixel in the side I don't want.

I would appreciate any solution or suggestion on how to achieve my goal. Thx in advance.

Edit. This is working in a Windows Server 2012 under IIS 6.0 developed with VS 2015 Professional in the NET 4.5 Framework

Edit: I mean 55 px to the right, but the best solution would be to the next point in the X axis

Edit: this is the content of web.config.

    <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
    <validation validateIntegratedModeConfiguration="false" />
      <remove name="ChartImageHandler" />
      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
        path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        validate="false" />
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
          assembly="System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <compilation debug="true" targetFramework="4.5">
        <add assembly="System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <httpRuntime targetFramework="4.5"/>

I am new to ReactJs. I am working with and reactjs to create a crud application. I have displayed the table. Now I am trying to insert values into table from forms. Please let me know how to do the same. I have shared the controller and reactjs code.


public class EmployeeController : ApiController
    EmployeeEntities db = new EmployeeEntities();

    public IQueryable<EmployeeTable> GetEmployeeList()
        return db.EmployeeTables.AsQueryable();

    public void InputEmployee()



    var EmployeeRow = React.createClass({

      render: function () {


  var EmployeeTable = React.createClass({

      getInitialState: function(){

      componentWillMount: function(){

          var xhr = new XMLHttpRequest();
'get', this.props.url, true);
          xhr.onload = function () {
              var response = JSON.parse(xhr.responseText);

              this.setState({ result: response });

      render: function(){
          var rows = [];
          this.state.result.forEach(function (item) {
              rows.push(<EmployeeRow key={item.EmployeeID} item={item} />);
  return (<table className="table">




  ReactDOM.render(<EmployeeTable url="api/Employee/GetEmployeeList" />,

input form component:

var InputValues=React.createClass({
          <label id="firstname">First Name </label><br/>
          <input type="text"  placeholder="Enter First Name" ref="firstName"   />
          <br/><br/><label id="lastname">Last Name: </label><br/>
          <input type="text"  placeholder="Enter Last Name"  ref="lastName"   />
          <br/><br/><label id="gender">Gender: </label><br/>
          <input type="text"  placeholder="Gender"  ref="gender"   />
          <br/><br/><label id="designation">Designation: </label><br/>
          <input type="text"  placeholder="Enter Designation"  ref="designation"   />
          <br/><br/><label id="salary">Salary: </label><br/>
          <input type="number"  placeholder="Enter Salary"  ref="salary"   />
          <br/><br/><label id="city">City: </label><br/>
          <input type="text"  placeholder="Enter City"  ref="city"   />
          <br/><br/><label id="country">City: </label><br/>
          <input type="text"  placeholder="Enter Country"  ref="country"   />
            <button type="button" onClick={this.handleClick}>Submit</button>

I am trying to show list of employees to view by following code. I have tblemployee class & tblDept class.

        EmployeeViewModel EmployeeVM = new EmployeeViewModel();
        MvcEmployeeEntities db = new MvcEmployeeEntities();
        List<TblEmployee> emplist = db.TblEmployees.ToList();

        List<EmployeeViewModel> EmpVMlist = emplist.Select(
            x => new EmployeeViewModel { 
                Emp_ID = x.Emp_ID, 
                Emp_Name = x.Emp_Name, 
                Emp_Number = x.Emp_Number, 
                DeptID = x.DeptID, 
                DeptName = x.tblDept.DeptName }).ToList(); // Error here

at this point deptName shows error saying

String can't be implicitly converted to NamespaceModel Class.

Is they any way to implicitly convert it ?

Note I have a Public virtual tblDept deptName {get;set;} as it is driven from tbldept class

public class EmployeeViewModel
    public int Emp_ID { get; set; }
    public string Emp_Name { get; set; }
    public Nullable<int> Emp_Number { get; set; }
    public Nullable<int> DeptID { get; set; }
    //virtual to use an other tble with in this tble, to get set there tblValues
    public virtual tblDept DeptName { get; set; }

I'm new to this is it is possible to send a textbox value from an ASP.NET MVC view to a SQL Server variable.

For example:

  • ASP.NET MVC view: Name:mike

    html code:

  • SQL query:

    DECLARE @value varchar(10)  
    SET @value = '@name'

Is it possible?