.NET Programming





The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

Share tech news, updates, or what's on your mind.

Sign up to Post

How to add a reference to Microsoft.Web.Management.Server reference in my c# project?

I'm extracting links from html using HtmlAgilityPack  but i'm getting a lot of unwanted rubbish

I have a list of wanted hosts how might I filter the links against this list?

using System;
using System.Xml;
using HtmlAgilityPack;
using System.Text.RegularExpressions;

public class Program
	public static void Main()
		var html =
    <div class='content'>
      <div id='post_message_30829575'>
        <a href='https://example.com/foo/123adj'><img src='https://example.com/foo/123adj/thumb.jpg'></a>
        <a href='https://example.com/foo/bar'>Link to foo bar</a>
        <a href='https://wanted.com/foo/bar'>Link to foo bar</a>
        <a href='https://rubish.com/foo/bar'>Link to foo bar</a>

        var htmlDoc = new HtmlDocument();
		string [] hosts = {"exasmple", "wanted"};

         var HTMLBody = htmlDoc.DocumentNode.SelectSingleNode("//body");
            foreach (var Node in HTMLBody.DescendantsAndSelf())
				var linkNodes = Node.Descendants("a");
				foreach (HtmlNode linkNode in linkNodes)
					HtmlAttribute link = linkNode.Attributes["href"];
					HtmlNode imageNode = linkNode.SelectSingleNode(".//img");
                                       // Don't need images
					if(imageNode == null)
						Console.WriteLine("Link value: {0}", link.Value);

Open in new window

When using asp.net web forms or asp.net mvc and using a gridview or an html table holding a sql server table with large amount of records and you want to allow exporting of the data to pdf.
What solution or technology do you normally use to export the large amount of data to pdf quickly?

I am having trouble to install .net framework 3.5 or 4.o  in Window 10 enterprise due to WSUS server we have.

Any suggestions are appreciated!

Thank you very much in advance!
Hi all
i got

cie as date



I need

Jueves 14 de Marzo del 2019

Thursday 14 of march of 2019

or some like that, the needment is that give me the day as text format

tsm experts
The code below works, but I don't need it to be long data.
I've tried replacing the "LONGTEXT" with "SHORTTEXT" but that just gave me an string error.

If strBomPartCount.Length > uintTableCurrentColumnCount Then
                For columnIndex = uintOffSet To strBomPartCount.Length
                    oQuery = "ALTER TABLE PcbBom ADD COLUMN PnQty" & (columnIndex - 4) & " LONGTEXT"
                    oComm = New OleDbCommand(oQuery, oConn)

            End If

Thanks in advance.

I have following codes.
I have myCollection variable that contains all the Web elements.  I am using two paths using XPath and or('|') operator because I need different things from the objects that these two different paths gives.
From the elements from the first path(//div[@role='region' and //@my-label] ), I want to get Text properties.
From the elements from the second path(//button[@role='button' and //@my-label]), I want to get the values of 'my-label' attributes. (the Text properties for this elements are "")
After that, I want to put all these too myList<string>.
Obviously I am getting errors on my Linq query(at Select statement).
What's should I do to accomplish this?

public IReadOnlyCollection<IWebElement> myCollection => _driver.FindElements(By.XPath("//div[@role='region' and //@my-label]  | //button[@role='button' and //@my-label]"));

var myList = new List<string>();
myList = myCollection
                    .Select(a => a.Text or a => a.GetAttribute("my-label").ToString()) 
                    .Reverse() // Newest item first

Open in new window

Using Windows Forms

I have a tabcontrol , each page has a datagridview.  I know the  tab page name


let's say I have tabPage1  the datagridview on that tab is dgvPage1.   Now I want to get the selected row

int row = dgvPage1.CurrentCell.RowIndex;  

How can I do this if all I know about is the grid I want is   -- String  VariableName  =  "dgvPage1"  stored in a variable.

int row = (VariableName).CurrentCell.RowIndex;  
String Person = (VariableName).Rows[row].Cells[0].Value.ToString();
I am getting below error :
System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
   at System.Data.SqlClient.SqlBuffer.get_Int64()
   at System.Data.SqlClient.SqlDataReader.GetInt64(Int32 i)

Open in new window

This comes on line row[7] where it is assigning Date value. This is assigning to DataRow in Datatable , Please help.Thanks I checked there are data available in reader there is nothing like NULL for data. There is data present.

                    while (dr.Read() == true)
                        if (Uid!= dr.GetInt32(0))

                            row = table.NewRow();
                            rectificationId = dr.GetInt32(0);
                            row[0] = dr.GetInt32(14);
                            row[1] = IdTest; 
                            row[2] = dr.GetString(1); 
                            row[3] = dr.GetInt32(2); 
                            row[4] = dr.IsDBNull(4) ? 0 : dr.GetInt32(4);                           
                            row[5] = dr.IsDBNull(6) ? string.Empty : dr.GetString(6); 
                            row[6] = dr.GetString(11); 
                         [b]   row[7] = new DateTime(dr.GetInt64(12)); [/b]
                            row[8] = new DateTime(dr.GetInt64(8)); 
                            row[9] = new DateTime(dr.GetInt64(9)); 

Open in new window


I have a few user settings in my vb.net project. The problem I am having is that they are not updating when I save them. The settings are set in user in the project properties. My code is:

        My.Settings.ServerIPAddress = txtServerAddress.Text
        My.Settings.ServerUserName = txtServerUser.Text
        My.Settings.ServerPassword = EncodeServerData(txtServerPassword.Text)

The problem is in the following:

            If My.Settings.UpdateSettings = True Then
            End If

I use this so that when a new version is installed I get the old settings. I need the best of both worlds the user to be able to change the settings and them being preserved when new versions are installed.

Any help would be appreciated

Hi All,

I want to develop a application for starting and stopping VMs , it will utilise Azure powershell . should I use powershell and wpf or c# and wpf, if I develop in c# the guide interface, can I call powershell commandlets? is c# more flexible for developing wpf guis than powershell?

thank you in advance,
Need Sitecore and .NET MVC practice site

I will be placed on a client location in a few weeks and at that time will be granted access to the existing Sitecore database. Until then, I need some hands on practice with Sitecore.

First, what is the correct term for a Sitecore file? It's not a database, but what term do you use to describe it?

I will be using Sitecore with .NET C# MVC.

I have Visual Studio installed and SSMS, but may need to put on SQL Server as well.

What can you suggest? I will also have no access to the source code until I am at the client location, so I just need something akin to a sandbox where I can play around. An existing, working MVC site with an integrated Sitecore demo database would be best.

What can you suggest?

Have a vendor product CT FreightRater, an automated rating database used to calculate rates for loads we haul. We can enter hundreds of scenarios for rates like mileage, flat rate from point to point.
FreitRater recently did a changeover from running their WebService using XML, to using JSON. I have my JSON data conversion code ready, but need assistance setting up the front parameters that allow the HTTP URL, validation, etc.
In my RPGLE program, I use a product called RPG-XML Suite from Krengeltech. It supplies API's I can use to formulate my data into the JSON format, and that's working fine.
I can test through a program on the FreitRater Server called 'MultiRater'. This allows me to 'drop' in formed JSON statements to test against the rating database, and receive a response.
Unfortunately, FreitRater is unable to provide the specs for what these parameters are.
The only example I received from them to allow testing sending a RatingRequest example (C# .NET), is attached.

I'm also including the RXS_TransmitDS_t data structure used to 'send' to the FreitRater WebService in an attachment.

I need a 'translation' of sorts between the C# .NET example, to be able to  plug in those parameters to the RXS_TransmitDS_t data structure.



I have an rdlc report in Legal papersize. I have set the report properties to Legal. The problem I am having is when I load it in to the reportviewer  and go to print the pagesize under page setup is always set to letter so it has to be changed manually. I need to be able to set the page settings in reportviewer programmatically so I can switch between letter and legal sizes via the code.  I have tried various things but nothing seems to affect the page setup dialog. What is the correct procedure to do this. I am coding in vb.net.


Tips to mastering Sitecore

I have a rare opportunity to invest lots of time into learning Sitecore, in preparation for a job integrating Sitecore with a .NET MVC application. So, the more I learn now, the further I can go in implementing Sitecore.

What videos and topics can you suggest I did into to make the most out of this one month deep dive into Sitecore.

And what related technologies might I also consider?


I have JSON string looking like this:
         "due_date":"0000-00-00 00:00:00",
         "last_event":"2019-03-07 14:42:59",
         "reminder_dates":"0000-00-00 00:00:00",
         "user_details":"{\"first_name\":\"Webcars Logistik\",\"last_name\":\"\",\"company\":\"Webcars\",\"email\":\"logistik@webcars.se\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\",\"reg_no\":\"\",\"address\":\"\",\"telephone\":\"\",\"post_code\":\"\",\"city\":\"\"}",
         "created_date":"2019-03-07 14:42:05",
         "signed_date":"2019-03-07 14:42:59",
         "last_sent_emailreminder":"0000-00-00 00:00:00",
         "last_sent_smsreminder":"0000-00-00 00:00:00",
         "recipients":"[{\"email\":\"nordberg.peter@gmail.com\",\"full_name\":\"MUSICCENTER SKARA AB\"}]",

Open in new window


I need a versatile asp.NET Content Management System which can be used for various websites and web-apps, for instance...

- Brochure sites.
- Knowledgebase sites.
- E-Commerce sites.

I need a widely used CMS which has strong community/support base and lots of extensions/add-ons.

I don't mind paying a premium if the solution works.

Please can I have some recommendations.

Many thanks
I had an interview a couple of weeks ago and the guy asked me why APIs are called Restful. I said because they're stateless. I said with Web APIs, data is transferred via HTML and it can be XML , JSON, but Web Services can only be XML. (Something like that... of course I was nervous)

I didn't answer his question. I've been googling and reading about APIs for another interview I have today. What's the answer to that question?
Need a sample SQL Server database I can use to play around with

I have SQL Server 2014 installed and hope to goof around with a sample database which has lots of different object types already installed. In fact, I hope that

sys.objects table is filled with every possible permutation. I want this database for the sole purpose of raising questions in me about what things I may have not seen before.

Do you have a link so such a free database for me to download?

Please provide a list of SQL Database Objects

I am curious about whether "SQL Database Objects" makes you think of scripts, stored procedures, functions, views and triggers. Or, if there is a set of objects I may have not worked with yet.

Please confirm that those which I listed are in fact "SQL Database Objects" or list any that come to mind.

Does MVC.Razor have a future?

How do Angular and React co-exist with Razor? Or is it a binary choice?

Either, MVC.Razor OR Angular OR React?


Any advantage of EF6.CodeFirst on a static database?

I have used Code First on a new project, and it rocked. Once the migration scripts are created, the database gets updated whenever it's out of sync. Awesome!

I have also use Entity Framework on a database that was not allowed to change, in any way. For this, I did NOT use Code First.

But, I recently watched a video on Udemy which said even in my second case, the Code First can still save time.

Is this true?

Id so, please explain why this is the case.

Pros and more Cons of using SASS on a new MVC website?

I have not used SASS but hear it produces perfect CSS files. One downside is that everyone who needs to create classes must learn the SASS scripting language. Another may be that debugging time is much higher.

Are there, instead, good coding practices that all developers can follow, so they can avoid the negatives of using SASS and get some of the benefits of using standardized CSS?

(I am not sure if the MVC site will use the Razor View Engine, but does this change your opinion of using SASS?)

What .NET Technologies in a New MVC Application?

If you needed to architect a new  .NET MVC Application today, what would it consist of?

What version of .NET, MVC, might it be?
And what about Dependency Inversion?
What about Unit Testing?
What is your preferred Unit Test Framework?
What about AutoMapper?
How about a MOQ tool?

And what else am I forgetting to mention?

Is KPM the String-searching algorithm needed to give user a City Name search field?

I need to code a CityName input field which allows the user to type a few characters, then show the user the closest matches, in a list.

Can you break this out into what is generally needed for this algorithm to work? Is KPM a choice?

As you can see, I just need to get my arms around this, conceptually.

 I would appreciate any guidance you can provide me.


.NET Programming





The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.