Am struggling with configuring a basic EntityFramework7-powered API app... I'm following this tutorial :

I've got Book and Author models, BookContext, my connectionString in AppSettings.json. The ConfigureService method in startup.cs is set. I build the solution and I've run dnu restore a billion times.

I had to add EntityFramework.Commands to the dependencies list 'cause when I ran dnx ef I had this error :

dnx : Error: Unable to load application or execute command 'EntityFramework.Commands'. Available commands: web, ef.

Now all I've got when I type in dnx ef is this

dnx : System.InvalidOperationException: No service for type 'Microsoft.Dnx.Runtime.IApplicationEnvironment' has been registered.

My dnvm version : 1.0.0-rc1-update2 clr x86 win

dependencies in project.json :

  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true

  "dependencies": {
    "EntityFramework.Core": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.Commands": "7.0.0-beta8",
    "Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Framework.Logging.Abstractions": "1.0.0-beta8",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }

  "exclude": [
  "publishExclude": [

Startup.cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Data.Entity;
using TestEf.Models;

namespace TestEf
    public class Startup
        public Startup(IHostingEnvironment env)
            // Set up configuration sources.
            var builder = new ConfigurationBuilder()

            if (env.IsEnvironment("Development"))
                // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
                builder.AddApplicationInsightsSettings(developerMode: true);

            Configuration = builder.Build().ReloadOnChanged("appsettings.json");

        public IConfigurationRoot Configuration { get; set; }

        // This method gets called by the runtime. Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
            // Add framework services.

                .AddDbContext<BookContext>(options =>

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)






        // Entry point for the application.
        public static void Main(string[] args) => WebApplication.Run<Startup>(args);

BookContext.cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Data.Entity;

namespace TestEf.Models
    public class BookContext : DbContext
        public DbSet<Author> Authors { get; set; }
        public DbSet<Book> Books { get; set; }


  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Verbose",
      "System": "Information",
      "Microsoft": "Information"

  "AppSettings": {
    "SiteTitle": "Contoso Books"
  "Data": {
    "ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=ContosoBooks;Trusted_Connection=True;MultipleActiveResultSets=true"

I'm getting an unhelpful exception when running dnvm upgrade:

C:\Users\...\Visual Studio 2015\Projects\foo>dnvm upgrade
Determining latest version
Unable to find any runtime packages on the feed!
At C:\Users\banksd\.dnx\bin\dnvm.ps1:483 char:9
+         throw "Unable to find any runtime packages on the feed!"
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Unable to find on the feed!:String) [], RuntimeException
    + FullyQualifiedErrorId : Unable to find any runtime packages on the feed!

I also can't resolve "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" in a fresh ASP.NET 5 project.

Don't know if the two are related.

Any advise?

I'm working on a project that is a responsive website so it can be viewed on mobile and tablets. When running the project the site opens in IE 11 and looks great. When I publish the site and open it with IE 11 the div that holds the main content is dropped to the next line.

What am I missing to publish or set to have this correct? Thank you

How do I post all my checkbox values when using

I have a function to "select all" checkboxes in the entire datatable

however when I "post" the values back to the page, or even a different page it only ever returns the the checkboxes of the currently visible page.

And yes I have checked all other similar articles/posts but none of them actually answers the question. Some nice suggestions but nothing that actually works.

I am not a javascript expert so a fully working example would be nice. As if I could have worked it out I would not be asking the question.

I scoured the net and found this code, which is about the closest I have managed to get.

    $('#form1').submit(function () {
        $('input:checked', otable.fnGetNodes()).appendTo('#form1');

When I use Request.Form.AllKeys I only ever see the the values for checkboxes from which ever page of the datatable was selected at the time for the submit.

I use a Repeater to populate my (no issues there) and even if you route through the DataItems collection to find the controls on those checked boxes on the page that as visible are shown as checked.

I don't want to or need any debate to understand why, I'm ok with that I just need to know how to solve the problem.

Someone must have solved it so point me at the solution. If it's never been solved then I'm in the same boat with a lot of people I would suspect and I'm sure they would also appreciate a solution.

Thanks loads

I am working on project using mvc4 C# . I want to change some html element

attributes by c# like width , height etc. I have a simple (_Layout.cshtml) file.

        <link href="@Url.Content("file.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("html.css")" rel="stylesheet" type="text/css" />

So i am using html agility pack to load and save this file

HtmlDocument doc= new HtmlDocument();

List<string> linklist = new List<string>();
HtmlNodeCollection _node = doc.DocumentNode.SelectNodes("//link");

foreach (HtmlNode Node in _node)
    foreach (var sName in linklist)
        if (Node.OuterHtml.Contains(Name.ToLower()))
            var linkNode = HtmlNode.CreateNode("<link href=" + "@Url.Content(" + '"' + "~/links/../" + Name + '"' + ")" + "/>");
            HeadNode.ReplaceChild(linkNode, Node);

After saving file output is like this

        <link href="@Url.Content("file.css")"="" rel="stylesheet" type="text/css" />

        <link href="@Url.Content("html.css")" />

In (link href) saving some extra characters like ="

How can i avoid this problem .. Is there any other solution for parse html in c# for mvc.

Actually I want to Replace new path to give href attribute

My code to create my table head is the following:

CreateHeadTable(idDes, idT, ["#", "Empresa", "Dirección", "Consultar"]);

function CreateHeadTable(idDest, idT, arrayHead){
   var mytable = document.createElement("TABLE");
   mytable.setAttribute("id", idT);
   mytable.className = "display";
   mytable.cellPadding = 0;
   mytable.width = "100%";

   var thead = document.createElement("THEAD");

   var tr = document.createElement("tr");

   var th, cell;

   for(var row = 0; row < arrayHead.length; row++) {
       th = document.createElement("th");
       cell = document.createTextNode(arrayHead[row].toString());

  iniciarTabla(idT);   }

enter image description here

that word should be: "Dirección" and not "Direcci?n"

I'm using visual studio 2010 and MVC with razor cshtml and I put this in my layout main

<head> <meta content="text/html; charset=ISO-8859-1" /> </head>

there any way to fix that ??

I would need to create dynamic online forms, e.g. using ASP.NET MVC and Razor as view engine. So you would be able to select a form template, populate it, add new fields, etc.

Are there any references/guides I could follow? I tried searching but couldn't really find any. Creating a main template view with controller, and partial pages with sub-controllers could be one way. This way validation and transformations would be quite well encapsulated.

My code below doesn't work properly. I want my variable j to count +1 everytime in the for loop. But when i run the code its stays on 0. Can somebody please help me and tell me what i've done wrong?

    <script type="text/javascript">
    function test() {
    var columnChosen = [];
    @{  var j = 0;}
    var count = document.getElementsByTagName("select");

    for (i = 0; i < count.length; i++)
        dropdownlists.push(document.getElementById("Merchant" + i.toString()).value);
        if (dropdownlists[i] != "-- Select an attribute --") {

            temp = "@Model.Columns[j].ToString()";



My stack is ASP.NET (Nancy) with Razor view engine. But this may concern all technologies I suppose.
I have two LAN networks (let's call them Large network and Small network) and two servers (a.k.a Main server and Image server). Main server can be reached by computers from both networks but Image server is visible only for machines in Small network. I have website served by Main server which shows images from remote (Image) server:

`<img src="http://ImageServer/image.png"/>`

All is fine when computer from Small network is loading the webpage from Main server as it has access to Image server too (the same network). Problem occurs when the computer from Large network loads the webpage. The image is not loading because Image server is in Small network which is not accessible for machines from Large LAN.
Is there any way to force Main server to serve the image directly?

I'm having a problem in creating my new controller inside the "Controllers" folder provided by ASP.Net MVC API. I don't know how can I fix this thing. I already rebuild all solutions. But when I clicked the "Add" button the error says

Thanks in advance!

I am running on window 2012 R2 OS with IIS role installed on it. I have also installed websitepanel and add the websitepanel as a site in IIS.

I have created 3 Application pools for individual website :-

(1) Websitepanel Portal :- To run websitepanel. (2) Websitepanel Enterprise Server (3) Websitepanel Server

I have bind the application pool with all 3 websites. The problem is whenever i am going to start the websitpanel, the application pool of websitepanel crashes.

The browser gives the following error.

Service unavailable

Also IIS admin service not going to start. Asking me to search Event log.

I have checked my server usage and it is normal. I have 3 GB RAM and 35 GB diskspace on my server.

Can anyone help me in this regard.

I will try to explain with an explain because it is bit complicated.I would like to remove words from my sql table if the word's root already exist in table.So my table structure is like this

Words  Scores
car       5
book      11
cars       2
pen        10
tool       4
car's      8
tools      2

So in this case,since car is root of car's and cars , tool is root of tools,I would like to remove them and add their score on the root word and get my table like this;

Words  Scores
car       15
book      11  
pen       10
tool       6

Not: if there is "a" in the list then all words that starting with a going to be remove: for this I thought about having if condition like; if (string[i].Length>=3) but ofcourse it wont avoid all possibilities maybe there willbe word "book"and "booking" so booking is going to be deleted but it is ok.

Not: I am using web app and it is connected sql server.

I started a new MVC Web Application project for the RC2 release and I'm trying to add a class library as a project reference.

I added a simple class library to my project and referenced it and got the following in the project.json file:

"frameworks": {
  "net452": {
    "dependencies": {
      "MyClassLibrary": {
        "target": "project"

I can use this library in any of the Controllers and the Startup.cs files without any trouble but I get the following error at run time when I try and use the library from a Razor page:

The name 'MyClassLibrary' does not exist in the current context Output.WriteLine(MyClassLibrary.MyStaticClass.SomeStaticString);

It's weird because I'm getting intellisense for the class library when I'm editing the Razor page, and I can't find anything that says you can't use project references from here.

I thought it was hard enough getting this running under RC1 with the "wrap folder" in the class library project but this has me stumped.

I am going to create table using jquery on the basis of selection in dropdownlist..When I select any option in dropdown the blank table will be generated on the screen..But when i insert values in blank table and press submit then in action I got model but that model consist only properties in the table which I have added from Ajax..But it ignores value of dropdownlist which I have selected first..If I remove that ajax success code then it gives model with proper values but I wont get values in Table created by ajax success....

Here is my ajax code:

 $("#Award").change(function () {
        var selectdAward = $("#Award").val();
        var ServiceUrl = "/Nomination/CriteriasForAward?awardId=" + selectdAward;

            type: 'post',
            url: ServiceUrl,
            contentType: "application/json; charset=utf-8",
            error: function (xhr, err) {
            success: function (data) {

                for (var key in data) {
                    $('#criteriaTable tr:last')
                        .after('<tr><td><label>' + data[key].Id + '</label></td>' 
                        + '<td><label>' + data[key].Title + '</label></td>'
                        + '<td><input type="text" name=Model.Comments[' + key + '].Comment></td>'
                        + '<td><input type="hidden" name=Model.Comments[' + key + '].Id value=' + data[key].Id + '></td></tr>');

Please suggest the way to solve this problem..Thanks in advance

I need to implement the functionality where user will click on browse button and it will open a pop up showing full sitecore media library tree where user can select the file.(It will be good if we will not make use of SPEAK Class)

I have just upgraded my sample app from RC1 to RC2 and I can't find how to bind a specific section of my appSettings.json file to my own POCO anymore.

The sample at show that something like this should work:

services.Configure<AppSettings>(options => Configuration.GetSection("AppSettings").Bind(options));

But with the final RC2 bits the "Bind" method or extension method can't be found

Any idea where it lives now or if there is a new approach for this?

Thanks a lot for your help!

I have list of PDF files on website ( webforms). i want to open them with Save As option rather than it downlaods directly.

I tried to add download property to the link which didn't work. only was around seems to be HTTPHandler for *.pdf request.

I saw a piece of code for MVC based example here

return new FileStreamResult(stream, "application/pdf")
    FileDownloadName = "file.pdf"

How can i convert this to HTTPHandler in webform so that it open pdf files with Save As option.

I want to do it in a way so that when ever user click on any pdf file at that time Handler should come into action.


I can create another file handlePDF.aspx and write code there also and will change link of pdf file to below

<a href="handlePDF.aspx?file=file1.pdf">File One </a>

how can I start the ASP.NET Core with the dotnet CLI samples so that they don't listen to the localhost?

This command doesn't work:

dotnet run --server.urls=http://*:5000

I have written a custom html helper for creating checkboxes and I want to apply html attributes as an anonymous type but I can't use the "checked" property of the checkbox because the compiler thinks that I'm referring to the C# keyword:

@Html.CustCheckbox(p => p.SomeProperty, scope, htmlAttributes: new { checked = "checked" })

Which produces the error:

Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.

Is there a way around this, so I can still use my above helper. It works fine with other html attributes.

Hello what the source of this problem

System.Data.SqlClient.SqlException (0x80131904): Cannot insert the value NULL into column 'IDContant', table 'ComData.dbo.TContant'; column does not allow nulls. INSERT fails. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExe[enter image description here][1]cuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteScalar() at Admin_AddContant.InsertNew() ClientConnectionId:714aaecf-4cf0-451a-9552-3f45753b6f24 Error Number:515,State:2,Class:16

I am having a dialog box which I am trying to print. I am able to print everything from the dialog box except the textbox values.

Can someone please share any ideas on this?

<div class="calculator">
 <a href="#" onclick="printElement('.calculator')"> <img src="images/icon_print.png" />Print</a>

//Javascript code

function printElement(element) {
var text = document.getElementById("age_input").value;
w =;
document.getElementById("age_input").value = text;