I am seeing some weird bevavious with IE not sending a authentication cookie back to the server thinking its a third party cookie.It is a authentication cookie that Thinktecture issues to the site . I got a solution from somewhere saying

This was resolved by telling IE to present the cookie by adding the custom header "" into the STS web config.

Can someone please interpret this for me since there are no other answers available and the thread was pretty old. How do we send a cookie using customheader elements.


I've searched high and low here on SO and also read ALL of the pertinent documentation on New Relic's site.

I am attempting to capture method-specific information in the New Relic transaction trace from my C#.Net Web Forms page, but cannot find an example anywhere that uses both of these technologies together. I'm pretty sure that my problem is that I don't know which assemblyName to use. Here's a working example where I'm hoping to get the details about the method SleepForFive():


<%@ Page Language="C#" CodeFile="TestNewRelic.aspx.cs" Inherits="Sandbox_TestNewRelic" %>
    <form runat="server">
        <asp:Button ID="btnFiveSeconds" runat="server" OnClick="btnFiveSeconds_Click" Text="Sleep for 5" />
        <br />
        <asp:Label ID="lblResult" runat="server" />


using System;
using System.Threading;

public partial class Sandbox_TestNewRelic : System.Web.UI.Page

    protected void btnFiveSeconds_Click(object sender, EventArgs e)
        lblResult.Text = "Done";

    public void SleepForFive() { Thread.Sleep(5000); }



<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="urn:newrelic-extension">
    <tracerFactory >
      <match assemblyName="" className="Sandbox_TestNewRelic">
        <exactMethodMatcher methodName="SleepForFive"/>
      <match assemblyName="System.Web" className="System.Web.UI.Page">
        <exactMethodMatcher methodName="FrameworkInitialize" />
        <exactMethodMatcher methodName="OnInit" />

My Result

Please click this link to see the output from New Relic (not enough reputation to post it here...)


As you can see in the image, the Custom Instrumentation is working -- I'm getting the two System.Web methods I asked for -- What am I missing?

What must I change to see the SleepForFive() method?!? (If it's something really easy, then I'm going to have to eat my shorts). :)

My largely JSON web service is protected by Elmah. It does a great job of recording uncaught errors. However, when error happens the caller of the endpoint gets this response:

enter image description here

How can I send the actual error that Elmah recorded back to the user?

i created a wcf service for mobile all is working but i want to add a header in my json response:

This is the response:


what i want response is:


Is there an easy way to build an IQueryable that does an inclusive where.

var query = _db.table.Where(x => x.Active);

    query = query.Where(x => x.isCheck1);

    query = query.Where(x => x.isCheck2);

The code works when check1 OR check2 is true, but if check1 AND check2 is true I need it to return

query = query.Where(x => x.isCheck1 || x.isCheck2);

Hy all!

I'm developing a MVC 4.0 web application with C# and came accros the following error. In major browsers (Chrome, Mozilla Safari, etc...) when i click logout in my web application it does the correct, logout the current user. When i do the same operation on IE, dosen't work, i login with the new user, and IE keeps the last user until i press ctrl+F5. The only thing i'm using for authentication is Sessions, nothing more.

Someone came acrros this issue? i've tried clear cache, clear sessions with abadon, clear, removeall and nothing seems to work when i'm on IE.

If you guys need some more info to help me with that, i'll answer as soon as possible!!

I have a Web API project which provides the access to only Authorized users based on roles. We plan to scale to multiple such API projects in the near future which will use the same Authorization token. What I am doing is using a separate project which authenticates the user (using Facebook, Google or ActiveDirectory or any other authentication provider), and then generate an Authorization token which is consumed by all the API servers. To enable decryption of the token, I am sharing the machine key via web.config among all the application. This works fine. Now I would like to change the MachineKey every once in a while and share it among all the applications that utilize the Authorization token.

  1. How do I update the machineKey at run time among all the applications?
  2. Is there a programmatic way to achieve the same?
  3. I have read in a blog that updating machineKey's is not a good practice. If so, how do I avoid using the machine key altogether and create a system where the key's are not static?

My idea is to separate out the Authorization project from my WebAPI projects so that I don't implement and authentication system within all the WebAPI projects. Any pointers would be very helpful.

I have several .aspx page that use resource files, like this:

string TheLanguage = "fr"; //or "de", or "en" ... can be different for each request

CultureInfo newCulture = new CultureInfo(TheLanguage);
Thread.CurrentThread.CurrentCulture = newCulture;
Thread.CurrentThread.CurrentUICulture = newCulture;
Page.Culture = TheLanguage;

string SomePageText = GetGlobalResourceObject("SomePage", "SomeResource").ToString();

As you can see, TheLanguage can change at runtime. If I implement output caching on this page, will the page be cached with the language that was determined when the page ran through its lifecycle, and then when a new request comes in for a different language the output will be that of the previous run or will the caching take the different languages into account?


I'm trying to display AJAX popup with confirmation message for the user, but when the user is clicking the button automatically goes to the button click event without displaying the message. This is what I have:

<asp:GridView ID="GridView1" OnRowCommand="GridView1_RowCommand">
      <asp:TemplateField ItemStyle-HorizontalAlign="Center">
            <asp:ImageButton ID="imgButton1" RowIndex='<%# Eval("PostingID") %>' CommandName="Archive" CommandArgument='<%# Eval("PostingID") %>' runat="server" ImageUrl="/images/a.png" />
            <asp:Panel ID="pnlConfirm" runat="server" CssClass="modalPanel" Style="display: none; height:160px; border-color:#B6B6B4;">
                  <table class="featrEmpDivLoginPopup" style="height:160px; width:460px;" cellspacing="0" cellpadding="0">
                        <td id="divClose" runat="server" class="topimglhs533 hedding1" style="height:30px; background-color:#d3d8d2;">
                           <div id="jsAlert1_popupBody" style="position: absolute; font-family: Verdana,Arial; font-size: 9pt; padding: 2px; text-align: left; background-color: rgb(255, 255, 255); color: black; top: 34px; width: 450px; left: 1px;">
                              <div style="padding-top:20px; padding-bottom:5px; text-align:center;">Are you sure you want to Archive this posting?<br></div>
                        <td style="width:100px; margin-top:5px; text-align:center;">
                           <asp:ImageButton ID="btnUpdate" CommandName="Archive" ImageUrl="~/Images/btnarchive.jpg" runat="server" />
                           <asp:ImageButton ID="btnCancel" ImageUrl="~/Images/cancel2.jpg" runat="server" />
            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="imgButton1" PopupControlID="pnlConfirm"
               CancelControlID="btnCancel" BackgroundCssClass="modalBg" DropShadow="false"></ajaxToolkit:ModalPopupExtender>
            <!-- PANEL -->

So I'm expecting the popup to be shown when the user will click on imgButton1 but instead it goes to the event right away in the code behind.

Do you guys see anything wrong in this code?

Thanks in advance, Laziale

Explanation added, Sept 14:

In Firebug, I'm able to see these two errors in ScriptResource.axd:

enter image description here

Can that be related to the problem I have?

Better picture added:

enter image description here

I've a search box which is on a master page. i used request.form to get the value to be searched. it is working fine when the previous page is not a secure page but such as login page and other web page that is secure i get nothing value. any idea on how i can work-around this?

When I'm debugging an ASP.NET / ASP.NET MVC project, after installing web essentials, I can go on the browser, click on the part of the HTML which I want to investigate and with a simple click I can see the source code (Aspx) that has generated that visual part (html).

It's called browser link

Is it possible to achieve something similar in WPF?

I get this performance issue from visual studio (Prefer jagged arrays over multidimensional).
The code to be replaced is "//matrix".
How can i do this with my code?

      public static int LevenshteinDistance(string s, string t)
        int n = s.Length; //length of s
        int m = t.Length; //length of t

        int[,] d = new int[n + 1, m + 1]; // matrix

        int cost; // cost
        // Step 1
        if (n == 0) return m;
        if (m == 0) return n;
        // Step 2
        for (int i = 0; i <= n; d[i, 0] = i++) ;
        for (int j = 0; j <= m; d[0, j] = j++) ;
        // Step 3
        for (int i = 1; i <= n; i++)
            //Step 4
            for (int j = 1; j <= m; j++)
                // Step 5
                cost = (t.Substring(j - 1, 1) == s.Substring(i - 1, 1) ? 0 : 1);
                // Step 6
                d[i, j] = System.Math.Min(System.Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1),
                          d[i - 1, j - 1] + cost);
        // Step 7
        return d[n, m];

I have this Jquery code(see below) that allows the user to open a file browser and select multiple images, they then get displayed for the user to view, after which they can save them to the database but there is a problem, when you select multiple images all at once and then open them it displays fine and saves all the images to the database.

However when you select one and then click open, click browse again upload another image and so on they get displayed fine, but when the user saves them only the most recently selected image gets saved to the database, I would like to be able to select and open one at a time and then still save them all to the Database at once.

Thanks in advance! Heres the code:

<input type="file" name="files" value="" id="upload-image" multiple="multiple"/> <div id="thumbnail"></div><br />

jQuery(function ($) {
    var fileDiv = document.getElementById("upload");
    var fileInput = document.getElementById("upload-image");
    fileInput.addEventListener("change", function (e) {
        var files = this.files
    }, false)

    fileDiv.addEventListener("click", function (e) {
    }, false)

    fileDiv.addEventListener("dragenter", function (e) {
    }, false);

    fileDiv.addEventListener("dragover", function (e) {
    }, false);

    fileDiv.addEventListener("drop", function (e) {

        var dt = e.dataTransfer;
        var files = dt.files;

    }, false);

    function showThumbnail(files) {
        for (var i = 0; i < files.length; i++) {
            var file = files[i]
            var imageType = /image.*/
            if (!file.type.match(imageType)) {
                console.log("Not an Image");

            var image = document.createElement("img");
            var thumbnail = document.getElementById("thumbnail");
            image.file = file;

            var reader = new FileReader()
            reader.onload = (function (aImg) {
                return function (e) {
                    aImg.src = e.target.result;
            var ret = reader.readAsDataURL(file);
            var canvas = document.createElement("canvas");
            ctx = canvas.getContext("2d");
            image.onload = function () {
                ctx.drawImage(image, 100, 100)

I place several markers on a Google Map (v3) with the the title attribute set to swedish names. The values are outputted from C# and the source is a XML-file that has utf-8 as charset. When outputting the character ö I get &amp;#246;.

I call the google maps js as follows -> `https://maps.google.com/maps/api/js?sensor=false&language=sv. I have tried to do JSON.Encode(value) but it doesn't work.

I set the markers like this ->

var position = new google.maps.LatLng(value, value);
            marker = new google.maps.Marker({
                position: position,
                map: map,
                url: value,
                title: 'value from C#'

What do I need to do to make Google output å as å, ä as ä and so on? Thanks for the help!


When doing @(new HtmlString(value)), it now works.

I have this code, which creates a new "incident" partial and displays it BEFORE the last one. Is there a way to tell it to display it AFTER instead?

    foreach (var incident in Model.allIncidents.ToList())
        Model.newIncident = incident;
        @Html.Partial("IncidentBodyPartial", Model)

I try to write a Blog with MVC4 and have problems with the Post - Comment (1 to n), as well as with the Post - Tag (n to m) relationship, using code first.


public class Tag
    public int ID { get; set; }

    public string Name { get; set; }

    public IList<Post> Posts { get; set; }


public class Comment
    public int ID { get; set; }

    public string Name { get; set; }

    public string Email { get; set; }

    public DateTime DateTime { get; set; }

    public string Body { get; set; }


public class Post
    public int ID { get; set; }

    public string Title { get; set; }

    public DateTime DateTime { get; set; }

    public string Body { get; set; }

    public IList<Tag> Tags { get; set; }
    public IList<Comment> Comments { get; set; }

Using this code first, I get a database which looks like:

Comment n to 1 Post n to m Tag

Where for the n to 1 the foreign key to Post is in Comment and for the n to m a Cross Table was created.

Now, I created a Controller as well as a View to create a new Post with Tags.

When I look into my database, everything is filled correctly. The Post and Tags exist, and the Cross Table is filled with the IDs.

But now, when I want to render the Post in my View I want to get the data with @post.Tags, where @post represents my currently selected Post which has the correct Data (Title, Name etc), but for Tags, which is the IList<Tag> from my Model I get a NullPointer Exception. (The same goes for @post.Comments)

Although, when creating the Post:

new Post() { ID = -1, Tags=new List<Tag>(), Comments=new List<Comment>(), DateTime = DateTime.Now };

Almost got everything working with CKEditor plugin and the only problem left is to load the data already saved to the DB into the WYSIWYG editor.

If i try something like this in javascript as a test it works fine.

    var value = "<h1>Awesome</h1>";

    var config = {};
    editor = CKEDITOR.appendTo('editor', config, html);


So this creates the editor and actually tries to load the "html" variable into it but this is currently just empty.

So if I look in my DB I have a field called Description (nvarchar(max),null) which currently has this value: <h1>Awesome</h1>

But if I try to get this value in Javascript I get an error:

Uncaught SyntaxError: Unexpected token ILLEGAL 

And if i look at the console log it looks like this:

 var value = '<h1>Awesome</h1>
Uncaught SyntaxError: Unexpected token ILLEGAL 

I am developing an IOS application that requires users' responses to be shared with other users in real time. I am unsure whether this information should be shared at the controller level or the model level. Are there any best practices when it comes to this?

I want to show a custom 403 page in my MVC 2 application. I followed following link. I added following to my config file:

      <remove statusCode="403" subStatusCode="-1"/>
      <error statusCode="403" path="/403.htm" responseMode="ExecuteURL"/>

I am still seeing the default asp.net 403 error page. What's wrong? enter image description here

I am using code-igniter MVC framework. I am sending a array to my view but I could not get the array in my view.

This is my controller code:

public function edit($id)
    $record = $this->Start_model->get_entry($id);//receiving array from model 
    $this->load->view('edit',$record);//send array to my view

This is my array on controller that I send:

    [0] => Array
        ( [id] => 1 [name] => Hamza [age] => 20 [address] => audit and account [phone] => 03000000000  )

But when I call this array view I get this error: Undefined variable: record

This is how I am getting my array in view:

echo '<pre>';
echo '</pre>';

Now I know I am sending a array to my view but I want to know If there is array in my view or not. I can get record through another method but I think it is not a good practice. So anyone can help me how I can detect if there is a array in my view.