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)
                    .ToList();


//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
AS 
BEGIN
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
INNER JOIN ListOfValues_LOV LOV
ON LOV.[Text] = AB.AllocationStatusID 
WHERE AB.CLM_ID = @p_CLM_ID
END

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"), viewModel.id + file_1);

         file.SaveAs(path);
         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 => model.email == 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

[System.Web.Http.HttpGet]
        public void MarkOnline(string offline)
        {
            BookingLCPreview existing = db.Data.FirstOrDefault(u => u.email == offline);
            existing.isOnline = true;
            db.SaveChanges();
        }

[System.Web.Http.HttpGet]
        public void CreateCookie(string create)
        {
            HttpCookie myCookie = new HttpCookie("user" + create);
            myCookie.Value = create;
            myCookie.Expires = DateTime.Now.AddHours(2);
            HttpContext.Current.Response.Cookies.Add(myCookie);
        }

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

[System.Web.Http.HttpGet]
        public bool CheckCookie(string check)
        {
            if (HttpContext.Current.Request.Cookies["user" + check] != null)
            {
                if (HttpContext.Current.Request.Cookies["user" + check].Value == check)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                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.

[System.Web.Http.HttpGet]
        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);
                HttpContext.Current.Response.Cookies.Add(myCookie);
            }
        }

[System.Web.Http.HttpGet]
        public void MarkOffline(string online)
        {
            BookingLCPreview existing = db.Data.FirstOrDefault(u => u.email == online);
            existing.isOnline = false;
            db.SaveChanges();
        }

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
                ,Name=model.Name
                ,LastName=model.LastName
                ,DateOfBirth=model.DateOfBirth};
            var result = await UserManager.CreateAsync(user, model.Password);
            if (result.Succeeded)
            {
                //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

   UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                // 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");
            }
            AddErrors(result);
        }

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.

Controller

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

Layer

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);
                con.Open();
                SqlDataReader reader = com.ExecuteReader();
                while (reader.Read())
                {
                    SPMS_GanttChartModel value = new SPMS_GanttChartModel();
                    value.id = 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));
                    child_data.Add(value);
                }
            }

        }
        List<SPMS_GanttChartRootModel> array = new List<SPMS_GanttChartRootModel>();
        {
            SPMS_GanttChartRootModel value = new SPMS_GanttChartRootModel();
            value.data = child_data;
            array.Add(value);
        };
        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 (https://codeigniter.com/user_guide/tutorial/create_news_items.html) 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" />

</form>

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 }}

work

but

        {{ 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.

Post.cs:

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

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

        [Required]
        [MaxLength(16)]
        public string Title { get; set; }

        public string Body { get; set; }

        [Required]
        public Person Author { get; set; }
    }
}

Person.cs:

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; }

        [Required]
        public string FirstName { get; set; }

        [Required]
        public string LastName { get; set; }

        [Required]
        public string Email { get; set; }

        [Required]
        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:

 <tbody>
            @foreach (var item in Model)
                {
                    rowNo++;
                <tr>
                    <td>
                        @rowNo.ToString("000")

                        @Html.ActionLink("Edit", "Edit", new { id = item.Id }) 
| @Html.ActionLink("Delete", "Delete", new { id = item.Id })
                        </td>
    </tr>
    </tbody>

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');
    </script>";
    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert 1", 
    script);
    Response.Redirect("~/Index.aspx");

}

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?

EDIT

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.

Edit:

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 Asp.net 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:

Chart1.Series.Clear();

    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();
        b++;
    }

    Chart1.Series.Add(series1);
    Chart1.Series.Add(series2);

    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;
    Chart1.DataBind();

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.

    <configuration>
  <appSettings>
    <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
  </appSettings>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <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=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>
  </system.webServer>
  <system.web>
    <httpHandlers>
      <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        validate="false" />
    </httpHandlers>
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
          assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </controls>
    </pages>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
</configuration>

I am new to ReactJs. I am working with ASP.net 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.

EmployeeController:

[RoutePrefix("api/Employee")]
public class EmployeeController : ApiController
{
    EmployeeEntities db = new EmployeeEntities();

    [Route("GetEmployeeList")]
    public IQueryable<EmployeeTable> GetEmployeeList()
    {
        return db.EmployeeTables.AsQueryable();
    }      

    [Route("InputEmployee")]
    public void InputEmployee()
    {

    } 
}

EmployeeJSX.jsx:

    var EmployeeRow = React.createClass({

      render: function () {
          return(
              <tr>
                  <td>{this.props.item.EmployeeID}</td>
                  <td>{this.props.item.FirstName}</td>
                  <td>{this.props.item.LastName}</td>
                  <td>{this.props.item.Gender}</td>
                  <td>{this.props.item.Designation}</td>
                  <td>{this.props.item.Salary}</td>
                  <td>{this.props.item.City}</td>
                  <td>{this.props.item.Country}</td>
              </tr>

              );
      }
  });

  var EmployeeTable = React.createClass({

      getInitialState: function(){

          return{
              result:[]
          }
      },
      componentWillMount: function(){

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

              this.setState({ result: response });

          }.bind(this);
          xhr.send();
      },
      render: function(){
          var rows = [];
          this.state.result.forEach(function (item) {
              rows.push(<EmployeeRow key={item.EmployeeID} item={item} />);
      });
  return (<table className="table">
     <thead>
         <tr>
            <th>EmployeeID</th>
            <th>FirstName</th>
            <th>LastName</th>
            <th>Gender</th>
            <th>Designation</th>
            <th>Salary</th>
            <th>City</th>
            <th>Country</th>
         </tr>
     </thead>

      <tbody>
          {rows}
      </tbody>

  </table>);
  }

  });

  ReactDOM.render(<EmployeeTable url="api/Employee/GetEmployeeList" />,
          document.getElementById('grid'))

input form component:

var InputValues=React.createClass({
  handleClick:function(){
      this.props.onUserInput(this.refs.firstName.value,this.refs.lastName.value,this.refs.gender.value,this.refs.designation.value,this.refs.salary.value,this.refs.city.value,this.refs.country.value);
  },
  render:function(){
    return(
      <div>
        <form>
          <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"   />
          <p>
            <button type="button" onClick={this.handleClick}>Submit</button>
          </p>
        </form>
      </div>
    );
  }
});

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
                Return(EmpVMlist);

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?