Subscribe: Personal Site Starter Kit
Added By: Feedage Forager Feedage Grade B rated
Language: English
antiforgery  button  data  date  microsoft aspnetcore  new xelement  new  request  runat server  runat  server  text  token  view 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Personal Site Starter Kit

All Forums

All Forums

Last Build Date: Wed, 21 Feb 2018 23:31:22 -0800


Is it safe to use IP while accessing local machine files?


Is it safe to use IP while accessing local machine files?

Bootstrap/Nav Tabs not working after update


I am not sure what caused this (I am inclined to blame Team Foundation Server, because I just hate it), but here is what is happening.

We have these tabsets.


And these pages


This seems to comply with the tutorials I am seeing online.

It's important to note that this is happening site-wide, not just on this page.  Also, this worked last week before a particularly fateful TFS Get Latest.

Here is the symptom.

  1. When the second tab is clicked, the page pane blanks, and the second tab does not highlight.
  2. When the first tab is clicked again, it returns to the correct first pane and the first tab remains highlighted.

I figure either some library is not getting loaded, or the matching mechanism from the tabs to the panes has changed somehow.

Add Column Link in gridView


I’m trying to add the column in gridview datatable at the end. By click the link it will show the detail of the data. My codes as follows

 SqlConnection con = new SqlConnection(strcon);

             SqlCommand cmd = new SqlCommand("Select ID,[Date], [Name] from info order by [Date] desc", con);

            SqlDataAdapter daGrid = new SqlDataAdapter(cmd);

            DataSet ds = new DataSet();


            gridiview1.DataSource = ds.Tables[0];


How can i make my GridView only shows data based on a search field for example my Autogenerated ID


so I want my GridView only shows data based on my search and there should be edit and delete and update within the gridview itself also I tried by my own but when I link the textbox search that is linked with my database using sqldatasource then link that with the gridview the search works but it will ask me to refresh and then the edit and delete and update will disappear <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditDelete.aspx.cs" Inherits="test.EditDelete" %>

 Create New Records/Print Forms    Search For Records Based on Vendor Name     

Search Records by Date::  

webApi in old website - webforms


Hello, i have an old web site (not web application project vs) in 4.0 webforms c#.

i wan't add apicontroller and i create it in app_code (vs ask me before creating, Controller folder is not available), so i add global asax file and in application_start

name: "ActionApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional }

My controller il TestController public class TestController : ApiController
// GET api/
public IEnumerable GetHelloWorld()
return new string[] { "value1", "value2" };

but in my browser get http://localhost/api/test/get always have 404, and No type was found that matches the controller named

So, my controller always not found, What did I do wrong? 


How to pass Form data and ListBox data to controller through Ajax?


Hi, can anybody help me to find what is wrong with my this codes for passing form data and Listbox data to controller by ajax? Here is the ajax code: $("#btnGetData").click(function () {                                var button1 = "getdata";                 var listItms = $('#ChooseRight').val();   // this is Lisbox field in Razor view                 var formData = $('#GenForm').serialize();  //the Form ID of razor view                 var wildcardprodtype = $('#WildCardProdType').val();                                $.ajax({                     type: 'POST',                     url: '/Report/LongRunningProcess',  //controller name                                        data: JSON.stringify({                         button: button1,                         viewModel: formData,                         ChooseRight: listItms,                         WildCardProdType: wildcardprodtype                     }),                                   contentType: "application/json; charset=utf-8",                     dataType: "json",                     async: true,                     success: function (data) {                     }                 }); Here is the controller, in debug, I can see the data of "button", WildCardProdType are passed properly, but not the data of viewModel and ChooseRight list. Any reason why? public ActionResult LongRunningProcess(string button, ReportViewModel viewModel, List ChooseRight, string WildCardProdType) {    .... here is the @HtmlBegin form header: @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "GenForm" } )) { By the way, the current razor view use ReportViewModel as this: @model MVCPROD.Models.ViewModels.ReportViewModel [...]

Asyn ConfigureWait Question


Do I need to set ConfigureWait(true) on every async call if I am waiting for a Loading... panel to work and response back? Or can I just call the first one with a ConfigureAwait(true) and then every other one to the database ConfigureAwait(false)?


C# - How to find total rows affected when using EventLogReader (eventLogQuery)?


I'm trying to read eventlogs from a server which has about 100 000 records using class EventLogReader(eventLogQuery).

I'm using pagination and each page will show only 25 records in my screen. So, I will be reading 25 records out of total records for the first page and next 25 records for the second page and so on.

My question is how to get the total records count for the below snippet like total rows affected because of that eventLogQuery applied on full set of events?

EventLogReader reader = new 
                reader.Seek(SeekOrigin.Begin, filter.PageStart);

eventLogs.TotalLogs = **totalRowsAffected**;                    
EventRecord eventInstance = reader.ReadEvent();

int i = filter.PageSize;
while (eventInstance != null && i-- > 0)
  eventLogs.Entries.Add(new EventLogData
   Type = eventInstance.LevelDisplayName,
   Source = eventInstance.ProviderName,
   Time = eventInstance.TimeCreated,
   Category = eventInstance.TaskDisplayName,
   EventId = eventInstance.Id,
   User = eventInstance.UserId != null ? eventInstance.UserId.Value : "",
   Computer = eventInstance.MachineName,
   Message = eventInstance.FormatDescription(),
   FullXml = eventInstance.ToXml()
eventInstance = reader.ReadEvent();
return eventLogs;

looking for someone who some experience with the payflow SDK


I am looking for someone who has some experience with payflow gateway sdk for payflow link to help me getting strated with integration

thx for ur help

Event listener in Web API


I have a windows project which is using 3 party dlls to communicate. this 3 party dlls are also sending events which is been captured inside the windows project via events& delegates.

Note: the events fired by the 3 party dlls are the UDP packets.

I need to convert this project to Web API. I have added those dlls in my web api and I am able to communicate to send request and receive response via the dll's. Now, I have to receive the events from those dlls in web api.

Is there anything I can try to make it possible.

scale image based on a frame background


Hi all,

There are a lot of zoom and crop plugins in jQuery but what I am looking for is bit different.
I am in need to show a frame and user would zoom in/out image till it seems fit in that frame so that every image taken is proper in terms of angle and distance.

For example I want to save image of car in various views like Left side, Right Side and accordingly there would be preset frames which should appear as overlay when image is being uploaded for a particular view and until user sees that image is filling in frame or overlay, he can zoom in or zoom out and once it is in desired view then it should save image as final one.

Can anybody please tell me how to show overlay/frame to help user to upload image.

Vinod K.

Entity Framework "Database First" not generating Foreign keys (MYSQL)



my table has some foreign key constraints. except for one constraint all the other relationships are fine.

from MySQL workbench, I tried with reverse engineering to see all the relationships are added. 

in that, it shows all the relationships correctly.

but when it comes to the visual studio it not mapping to the table.

Appropriate Way of Creating a SQL View In ASP Core Code First Approach



Googling around led me to deduce that one following the Code First approach can't have a view created for database in the SQL and a model based on the same for an MVC view. The only method I came across was to create a model referring to a similar structured table and having a SQL view with the same structure be created replacing the table so created. In regard of using Code First approach to get an Entity Framework mapped to a view, instead of a table, when an initial migration file was generated, I commented out the portion referring to the said imaginary table, and right at the same position inserted the query as follows:

//Table Part Commented Out
    name: "D_XYZ",
    columns: table => new
    constraints: table =>

//SQL For View Inserted
migrationBuilder.Sql("CREATE VIEW [dbo].[D_XYZ] AS select ...");

However, I find that if I run the Update-Database the said database creates successfully with the required View instead of a table. However, to check it again, I dropped the said database and this time, when I Run the said ASP Core app by F5, the database initialized by it had a Table instead of a View?

  • Why is it so, while I had commented out the relevant portion in the migration file?
  • Isn't the Migration file used upon the launch? or it is based only on the Models as defined?
  • Upon completion of a project and at the time of the deployment, would a manual separate running of the Migration or a Query to drop a Table and replacing it with a View would be required?


Update textbox text



I have an asp form that has a grid view with radio buttons. I want to update the text of the textbox every time a new radio button is clicked like a counter but I don't want to refresh the page.

Any ideas/Suggestions?

Thank you

Insert white Spaces in XML to LINQ generated document


I am using the following code to generate the XML.

 XElement contacts =
new XElement("Contacts",
new XElement("Contact",
new XElement("Name", "Patrick Hines"),
new XElement("Phone", "206-555-0144",
new XAttribute("Type", "Home")),
new XElement("phone", "425-555-0145",
new XAttribute("Type", "Work")),
new XElement("Address",
new XElement("Street1", "123 Main St"),
new XElement("City", "Mercer Island"),
new XElement("State", "WA"),
new XElement("Postal", "68042")
This gives me

Patrick Hines

123 Main St
Mercer Island

but I want to generate an XML with white Spaces/newlines in before few elements. For Eg:
if I want to push few elements to the right like below..

          Patrick Hines

                     123 Main St
                       Mercer Island

I am reading this generated XML into a tool which needs such weird spacing in XML files else it fails reading XML files.

I am not sure if generating the above XML is possible with LINQ to XML or should I use XMLTextWriter ?

LINQ to retrieve the number of users registered per month



I have a user table, which contains the users registered to an application.

I need to retrieve the list  of number of users registered each month . The month should be taken from the CreatedOn field in the same table.

I need to generate report based on this data. so i need the output as follows

UserCount    Month

2                    Jan

3                   Feb

I am using mvc5 with EF6 to retrieve  the data. How can i retrieve the data in the above format using linq/lambda expression.

How To Change Month And Year To Fromdate And Todate In Sp


Dear all,

Can somebody help me to revise below original SP where it would display cardno for the month period. What I want is to display cardno by date range Eg, txtLog_date and txtCompleted_date
FYI, asp will call ashx file and from ashx pass the 3 parameter to sp as below


-- Batch submitted through debugger: db-deploy.SQL|6|0|C:\CorpServer\ATTD\Report\db-deploy.SQL

Alter PROC [dbo].[$_Rpt_vehicle]
@Card VARCHAR(16), -- Employee Card No.
@Year INT, -- Trx. Year
@Mnth INT, -- Trx. Month

@txtLog_date datetime, ------ FromDate newly added field passed from asp
@txtCompleted_date datetime ------------ ToDate newly added field passed from asp


SET @DtFr = CAST(CAST(@Year AS VARCHAR) + '/' + CAST((@Mnth+0) AS VARCHAR) + '/01' AS DATETIME)
SET @DtTo = DATEADD(month, 1,CAST(CAST(@Year AS VARCHAR) + '/' + CAST((@Mnth+0) AS VARCHAR) + '/01' AS DATETIME))

;WITH tData AS
INSERT INTO @Temp ( [Date], [WDay] ) SELECT mt.[Date], DATENAME(WEEKDAY,mt.[Date]) FROM tData mt


CardNo [EmplCard], Name [EmplName], [DepartmentDesc] [EmplSrcs], [InOut] [InOutDes],

TrDate [TrnxDate], TrTime [TrnxTmMn], TrController [TrnxTmMx],



CardNo = @Card AND YEAR(TrDate) = @Year AND MONTH(TrDate) = @Mnth
TrDate, [TrDay], TrTime, CardNo, Name, [DepartmentDesc], [InOut] , TrController
------------------- end of SP ---------------------------------

Now, my requirement is is to change the parameter type from month(int) and year(int) to txtLog_date(datetime) and txtCompleted_date(datetime)

because I already revised my asp parameter as this'2/1/2018'&txtCompleted_Date='2/22/2018'

The problem is that when it goes to above SP, it failed to show data ..

any advice how to revise above SP ?

Thanks a lot,

How to export data right?


I have a database with some data get by somewhere. 

Now i want to export the data to text files. But there can be many data. it can run many minutes.

  • I want to start export with one API call. In working state, no another call should can start another export. the export should mark each datarow (with subrows) after exporting
  • Another call should ask the export about his state
  • At finisch the export, the export should save an with state and notes in the database 

I have experimented and my actual code is not stable. Sometimes it break with no output or i get "New transaction is not allowed because there are other threads running in the session." Is there someway a tutorial how to build the scenario or any hints for me?

Apparently Random Error: "Antiforgery token validation failed. The antiforgery cookie token and request token do not match."


Background I have a relatively new ASP.NET Core 2 site. It's running on just one server, and I only restart the site once every few days when I upload an update. About once a day, a user's request fails due to rejection by the anti-forgery system. These are POST requests, and there's nothing particularly special about them. I'm including the anti-forgery value in the POST request, and 99% of the time, they work. The stdout log says, "Antiforgery token validation failed. The antiforgery cookie token and request token do not match." Errors I've included the relevant portions of the stdout log below. info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1] Request starting HTTP/1.1 POST [domain redacted] application/x-www-form-urlencoded 234 info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ValidateAntiforgeryTokenAuthorizationFilter[1] Antiforgery token validation failed. The antiforgery cookie token and request token do not match. Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery cookie token and request token do not match. at Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.ValidateTokens(HttpContext httpContext, AntiforgeryTokenSet antiforgeryTokenSet) at Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.d__9.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.ViewFeatures.Internal.ValidateAntiforgeryTokenAuthorizationFilter.d__3.MoveNext() info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[3] Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.AutoValidateAntiforgeryTokenAuthorizationFilter'. info: Microsoft.AspNetCore.Mvc.StatusCodeResult[1] Executing HttpStatusCodeResult, setting HTTP status code 400 info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[2] Executed action /Index in 2.6224ms warn: Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery[1] Antiforgery validation failed with message 'The antiforgery cookie token and request token do not match.'. For requests that result in the above stdout output, IAntiforgery.IsRequestValidAsync agrees by returning false. Here's a reduced example of a failed POST request and the associated cookie. POST: __RequestVerificationToken=CfDJ8MaM8-ULaotKhrvVVKXdGgUxork4jTkt343ArrABhTtbRVKMxPm7suOo6490GWo8QoQmFNt8iL1XjajwYezj_y3exGfXYM8pXgNPjkTuPgG-Hlzdw7Kg_hu_yiPkQo2KKjBZB5NOIWfPqBecVMEsKOQ Cookie: .AspNetCore.Antiforgery.ClRyCRmWApY:CfDJ8MaM8-ULaotKhrvVVKXdGgVKKYfnM3HQVB1OgVz-ty6QaZDh-PDHS5pj7D-dIZRDx85uTCXjdTvV8FoAKLlti4poxLBrzze7dkGCSbWFgWUbr-UDxSyHFgOw2dpV0gvA0M7R39ENzzJiboDv11aUQPM The error message said, "The antiforgery cookie token and request token do not match." The POST and cookie strings are not exact matches, but in my experience, they never are. They look very similar to every other anti-forgery POST and cookie pair I normally see, so I can't deduce what's going wrong here. ASP.NET Core 2 on GitHub I decided to look at the source code of ASP.NET Core 2. I found this file, especially line 145: That line gets the message "The antiforgery cookie token and request token do not match." from this file at line 134: [...]

asp label value doesnt set from codebehind



I have some buttons in my page , but only 1 that i needed to work fails to set a value in label.text. Kindly please anyone help me , to identify the issue where the label cannot be set from a "btnPrintPDF_Click" button while the other buttons could assign just fine.



.cs Codebehind

protected void btnPrintPDF_Click(object sender, EventArgs e)
lblerror.Text = "btnPrintPDF_Click";

foreach (GridViewRow row in gvContactList.Rows)

CheckBox checkbox = (CheckBox)row.FindControl("cbRowSelect");

//Check if the checkbox is checked.
//value in the HtmlInputCheckBox's Value property is set as the //value of the delete command's parameter.
if (checkbox.Checked)

string RowID = Convert.ToString(gvContactList.DataKeys[row.RowIndex].Value);




catch (Exception ex)
string ext;
ext = ex.ToString();