.NET Programming

133K

Solutions

38K

Contributors

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

Hello Experts,

I am looking for some assistance with searching for a match against a specific string in a text file using Powershell. I have researched numerous methods so far and can't seem to determine how to satisfy this criteria:

 Sample data
I need to look for the string '20180125', and export the entire line to a new file ONLY when that string is found in the position in Green. If it is located at the red position, I don't care about the line. (But I DO care if it i located in both positions...)

I've tried some REGEX variations but I am having difficulty. I thought perhaps if I used Search-String with a pattern that it should suffice, I just can't figure out what that pattern needs to look like to match '20180125' only when it exists in the position in GREEN.
0
Never miss a deadline with monday.com
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

How to install Resharper on Visual Studio 2017?

I have the license ID handy, but forgot how.

Thanks.
0
Hi,

I have all of a sudden starting getting the following error on a .net application:

Error
I'm confused by this error as I cannot find out why it is happening.

I am hoping someone is able to help me.
0
How Vulnerable are query string parameters and their values?

I am curious how vulnerable a website is to hacking that has little validation on the query string params.

Some argue that:
1) an unrecognized query string parameter can do no harm
2) it's too much work, since the program is always in flux, so the "poor stepchild" would not keep up
3) the code to block this (locally at least) is fragile and will always delay a solid release
4) there will be many more failed log-ins than blocked hackers

What are your thoughts on this topic?

And how does using a Web Application Firewall change the discussion?

It seems that if the benefits to security were small or non-existent, the Security Industry would not waste its time closing this vulnerability.
0
I frequently find myself tracing through the class hierarchy to determine if a class is IDisposable. Or even worse, examining a class to determine if it should be IDisposable.

Sometimes they are; sometimes they aren't.

Is there an easier faster way?
0
I have a viewbox which points to a static resource "icon-volume" which draws an SVG object using XAML.

I would like to click the viewbox and change the image.

<Viewbox Margin="0,0,5,0" x:Name="ViewboxStartDetectionUnit" MouseLeftButtonDown="ViewboxStartDetectionUnit_MouseLeftButtonDown" Style="{DynamicResource StyleTextViewboxWindowTitle}">
 <ContentPresenter x:Name="ContentStartDetectionUnit" ContentTemplate="{StaticResource icon-volume}"/>
</Viewbox>

Open in new window


How can I change the ContentTemplate of this  Viewbox programatically?
0
In a very simple Silverlight Application I have a DomainService Class which has a single method that returns a list of Letter Objects.

The application works fine when I run it in VisualStudio. However, when I publish it to a folder on my Windows 10 local machine and run it using IIS (version 10.0.166299.5) I get the following error:
The remote server returned an error: NotFound. at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error) at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception error) at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.b__17(Object )

I supect this is due to something being wrong in missing in my WebConfig file. My WebConfig Currently looks like this:

<?xml version="1.0"?>

<configuration>


    <system.web>
      <compilation debug="true" targetFramework="4.6" />
      <httpRuntime targetFramework="4.6" />
    </system.web>




  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
  

Open in new window

0
I am installing a Visual Studio 2017 application developed on .NET framework 4.5.
The client does not use Microsoft SQL Server but I would like to use SSRS for reporting. Is there a standalone SSRS that can provide reporting without Microsoft SQL Server installed.
0
I am working on a C# application that is supposed to monitor an old VB6 application. One of the things I need to do is determine which windows are currently open. I have been able to get the window handles but I need to turn them into something more useful that will give me information about the windows. I'm sure there's a Win32 API call to do this but I don't know what it is. Can anyone help me turn a windows handle (IntPtr) into a useful structure that will tell me about the window itself?
0
I need a aspx .net HTML Editor that will save the HTML EXACTLY as it is pasted in

And then show the same exact thing on open and edid/save.
0
Hire Technology Freelancers with Gigs
LVL 12
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

I am trying to work with a simple C# app but I get a “Method must have a return type” and “Identifier expected” errors.
The errors occurs on the following line:
 
OpenFile(fileName);

Open in new window

Full Code:
    private void OpenFile(String AFileName)
    {
           Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.UseShellExecute = True;
            psi.FileName = AFileName;
            p.StartInfo = psi;
            p.Start();
    }
        private void button1_Click(object sender, EventArgs e)
        {
            //*
            string fileName = "";
            if (radioButton1.Checked == true)
            {
                 fileName = "c:\test_3\johnson.pdf";
            }
            if (radioButton2.Checked == true)
            {
                 fileName = "c:\test_3\ross.pdf"};
            }
        OpenFile(fileName);
    
        }

Open in new window

Please help resolve the errors.

This is not homework for a class. It is self-study using books.
0
I am trying to work with a simple C# method but I get a "Only assignment, call, increment, decrement, and new object expressions can be used as a statement" error.
The error occurs on the following line:
 p.Start;

Open in new window

Full Code:
private void OpenFile(String AFileName)
    {
            Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = AFileName;
            p.StartInfo = psi;
            p.Start;
    }

Open in new window

I am trying to convert the following VB.Net sub into a C# method:
Public Sub OpenFile(ByVal AFileName As String)
        Dim psi As New ProcessStartInfo()
        psi.UseShellExecute = True
        psi.FileName = AFileName
        Process.Start(psi)
    End Sub

Open in new window

Please help resolve the error.

This is not homework for a class. It is self-study using books.
0
Need to find where query params are added to a .NET Solution.

I need to search through multiple solutions and find the many places where query string params are added to the URL. So, I wonder about all the ways this can be done.

Have you got any searches I can do that would help me track those down?

My fear is that finding them all would be nearly impossible, given you can insert a query parameter just be concatenating a string.

But, please make suggestions about explicit commands and objects used, and other more general keywords I can search for, to discover where URL's are being created.

Thanks
0
Assessing Vulnerability from URL parameters

I am in the processing of helping secure a .NET website against URL hacking. So I have spent some time adding a whitelist of valid domains and sub-domains. But what about query parameters?

My instincts are to add a second whitelist of valid query string parameters, but does that do anything to protect me?

I suppose a determined hacker could, with time and experimentation, find a query string param that has some exploitation value.

What do you think?

My worry is that whitelist of query string params may be difficult to generate, as this website is quite large. And there is always a risk of rejecting a legitimate request. The query string exposure is about revealing key data in the URL, but I am asking whether there is value in asserting that each query string param is in a whitelist of such params?

So, this is a customer service versus hack risk, threat assessment. And if there is little or no measurable reduction in threat, then this parameter whitelist could cause more harm than good.

Thoughts?

Thanks.


Thanks.
0
Looking for Test URL's to try against my Anti-XSS code

Can you post some URL's or a link to a site where I can get dozens of various URL's that I can use to test against my Anti-XSS URL Hack code?

I need domains in the return URL, query string parameters, to see what my code can do.

Thanks
0
I am getting this exception message
Message = "You must write ContentLength bytes to the request stream before calling [Begin]GetResponse."

Here is my code (Partially)
GlobalOneResponse objCharge = new GlobalOneResponse();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "POST";
request.ContentLength = xmlString.Length; 
request.ContentType = "text/xml";
                       
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.UTF8);
requestWriter.Write(xmlString);
WebResponse webResponse = request.GetResponse();
Stream webStream = webResponse.GetResponseStream();
StreamReader responseReader = new StreamReader(webStream);

responsedata = responseReader.ReadToEnd();                      
responsedata = responsedata.Replace(System.Environment.NewLine, null);

Open in new window


The bad line is highlighted here
SP
0
The code below is being used to monitor c:\test but doesn't.  I can create a file in the test directory and change it but never get notified.

Any idea why not?

private void Form1_Load(object sender, EventArgs e)
        {
            FileSystemWatcher watcher = new FileSystemWatcher("C:\\test\\", "*.txt")
            {
                IncludeSubdirectories = true
            };

            toolStripStatusDirectory.Text = "Monitoring C:\\test";
            statusStrip1.Refresh();

            watcher.NotifyFilter &= NotifyFilters.LastAccess | NotifyFilters.LastWrite
                      | NotifyFilters.FileName | NotifyFilters.DirectoryName| NotifyFilters.CreationTime;

            watcher.Changed += new FileSystemEventHandler(OnChanged);
            watcher.Created += new FileSystemEventHandler(OnChanged);

            watcher.EnableRaisingEvents = true;
        }
        private void OnChanged(object source, FileSystemEventArgs e)
        {
            // Specify what is done when a file is changed, created, or deleted.
            toolStripStatusCurrent.Text = "File //: " + e.FullPath + " " + e.ChangeType;
        }

Open in new window

0
Blocking a period at the end of a whitelisted URL?

I have a RegEx which is partly working to help verify a white listed list of domains, with '|' as delimiter, is working

              string regEx3 = @"https?://(" + whitelist + ")(.*)\\?(goto|returnurl)=https?://(" + whitelist + ")";

But I need to BLOCK a domain which uses my white listed domain as a sub-domain.


sso.mydomain.com is okay, but the following is not
sso.mydomain.com.badURL.com


I need to make the RegEx fail when it discovers a period after the white listed domain.

How?

Thanks
0
Hi all.

I want to add a datetimepicker to a datagridview control in vb.net. I've looked online for some examples and found one that works but with one exception. If I click the the right side of the cell, the calendar icon appears and  I then click the down arrow the calendar pops up and I'm able to select the date. But, if I were to click the middle of the cell it defaults to today's date and if I don't click the calendar icon on the right and keep it selected to today's date then it doesn't hide the datetimepicker (ie. AddHandler dateTimePicker1.CloseUp, AddressOf DateTimePickerClose in my code below), and it won't clear the cell (i.e.w1.Cells.Item("ExpectedShipDate").Value = "" in my code below). It's as if the datetimepicker control is frozen.

I also attached a print screen, the last row is the one with the weird behavior. If you notice, the date is all the way to the left and the calendar icon with the down arrow still appears. If you click the icon and down arrow it pops up the calendar again and you can choose a date but the cell won't have that new selected value but rather the one that was there before. If you click the icon that is in the column to the right it'll clear the value of the cell (i.e.w1.Cells.Item("ExpectedShipDate").Value = "") but you'll still see the 2/13/2018 with the calendar icon in the cell.

Ideally, I just want to clear the cell (values and datetimepicker) when I click the "clear" icon to the right whenever the end user selects …
0
Free Tool: IP Lookup
LVL 12
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

I am trying to work with a simple C# method argument but I get parenthesis and semicolon expected errors.
Code:
private void OpenFile(ByVal AFileName As String)

Open in new window

I am trying to convert the following VB.Net sub into a C# method:
Public Sub OpenFile(ByVal AFileName As String)
        Dim psi As New ProcessStartInfo()
        psi.UseShellExecute = True
        psi.FileName = AFileName
        Process.Start(psi)
    End Sub

Open in new window

Please help resolve the argument error.
This is not homework for a class. It is self-study using books.
0
This is Web Forms, C# (Not MVC)

We have our website with Forms authentication. A client of the company ran security scan on our site and said this is a security risk that needs to be fixed:

1. User opens the browser, types in username/password and logs in
2. User can now open another tab and log in again
3. User can open another browser session and log in

So, the site is allowing multiple logins and we've been asked to fix this.

I had this idea
 When user logs in, we set a flag in the database. If user opens another tab or another browser session to log in again, we can check that flag and prevent a double login.

But, what if user X outs and doesn't click on the "log out" button?

Any ideas on how to go about this?
0
I am having trouble understanding this RegEx:

            string redirectRegex = @"(.*)?\?(.*)?(" + redirectparams + "){1}\\=(.*?[^&]+)?&?(.*)?";

Please break out each element and explain what that element does.

Thanks
0
RegEx: Allowing for an optional path in the URL

The underlined portion MAY contain chartacters and MAY NOT.

            string regEx = @"^https?://(" + Regex.Escape(redirectWhitelist) + ")_______\\?(goto|returnurl)=https?://(" + Regex.Escape(redirectWhitelist) + ")";

This RegEx requires a certain URL, but I do not want to require that:

            string regEx = @"^https?://(" + Regex.Escape(redirectWhitelist) + ")/openup/UI/Login\\?(goto|returnurl)=https?://(" + Regex.Escape(redirectWhitelist) + ")";

What can I place into the RegEx in place of  "/openup/UI/Login"

So that anything is acceptable, including nothing?

Thanks.
0
I am trying to work with two radio buttons in a simple VB.net app that allows a user to select and open a PDF using the Process object. One PDF will be assigned to each radio button. The code is shown below. I get the following error: "Argument not specified for parameter ‘AFileName’ of ‘Public Sub OpenFile(AFileName As String)."

Please help resolve the error.

This is not homework for a class. It is self-study using books.

Code:
Public Class Commands
    Public Sub OpenFile(ByVal AFileName As String)
        Dim psi As New ProcessStartInfo()
        psi.UseShellExecute = True
        psi.FileName = AFileName
        Process.Start(psi)
    End Sub
End Class

Open in new window


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fileName As String
        Dim Commands As New Commands
        If RadioButton1.Checked = True Then
            fileName = "c:\test_3\johnson.pdf"
        End If
        If RadioButton2.Checked = True Then
            '        Else
            fileName = "c:\test_3\ross.pdf"
        End If
        MessageBox.Show("File name is: " + fileName)
        Commands.OpenFile()
    End Sub
End Class

Open in new window

The following code causes the error:
Commands.OpenFile()

Open in new window

0
I am trying to work with two radio buttons in a simple VB.net app that allows a user to select and open a PDF using the Process object. One PDF will be assigned to each radio button. The code is shown below. I get the following warning: "Variable ‘fileName’ is used before it has been assigned a value. A null reference exception could result at runtime."

Please help resolve the error.

This is not homework for a class. It is self-study using books.

Code:
Public Class Form1

    Private Sub OpenFile(ByVal AFileName As String)
        Dim psi As New ProcessStartInfo()

        psi.UseShellExecute = True
        psi.FileName = AFileName
        Process.Start(psi)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fileName As String
        If RadioButton1.Checked = True Then
            fileName = "c:\test_3\johnson.pdf"
        End If
        If RadioButton2.Checked = True Then
            fileName = "c:\test_3\ross.pdf"
        End If
        MessageBox.Show("File name is: " + fileName)
        OpenFile(fileName)
    End Sub
End Class

Open in new window


The warning occurs on the following line:
MessageBox.Show("File name is: " + fileName)

Open in new window

0

.NET Programming

133K

Solutions

38K

Contributors

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.

Vendor Experts

Gil FeldmanMonday Learn more about Monday