Category Archives: Website Dev

Azure DevOps Export to Excel Error TF400051

When requesting an Open in Excel a pop-up shows this error.

TF400051: Cannot process URL when attempting to open a query in Excel….

Azure DevOps

This is maybe your installed Visual Studio (VS) that is a lower version recently. Example. Before you’ve install VS 2017 and then VS 2019, but recently you’ve install VS 2010 due to a legacy project support. That sometimes changes a registry that produce this error.

To fix it follow the following:

  1. Open RegEdit
  2. Navigate to

    Computer\HKEY_CLASSES_ROOT\tfs\shell\open\command
  3. Change the value to the following

    C:\Program Files\Common Files\Microsoft Shared\Team Foundation Server\15.0\TfsProtocolHandler.exe “%1”
  4. Save the changes.

That’s it. Try exporting again and it should work now.

God Bless!
Thanks,
Thomie

Dynamic Object in C#

In my experience there was a need to create an object and its properties dynamically. Namely as follows:

thisIsMyObject.MyProperty1 = "AnyValueOfAnyType";
thisIsMyObject.MyProperty2 = true;
thisIsMyObject.MyProperty3 = 1;

To do this there could be different approaches like using a dictionary

Dictionary<string,object> c = new Dictionary<string,object>();
//adding a value
c.Add("MyProperty1", "AnyValueOfAnyType");
c.Add("MyProperty2", true);
c.Add("MyProperty3", 1);
//getting the value
c["MyProperty1"]; //AnyValueOfAnyType
c["MyProperty2"]; //true
c["MyProperty3"]; //1

But you may also use a dynamic object like as follows

var c = new System.Dynamic.ExpandoObject() as IDictionary<string, Object>; //namespace for note only
//adding a value
c["MyProperty1"] = "AnyValueOfAnyType";
c["MyProperty2"] = true;
c["MyProperty3"] = 1;
//getting the value
c["MyProperty1"]; //AnyValueOfAnyType
c["MyProperty2"]; //true
c["MyProperty3"]; //1

This way its more presentable and like using an array.

God Bless!

Thanks,
Thomie

Visual Studio Extension -Ngrok

Ngrok is now widely being used. From simple web development up to complex development. Is hard to run Ngrok everytime you are coding specially when using IIS Express that if not configured to use a specific IP it will generate random port which is a hard to map.

Thankfully there is a plug-in for our beloved Visual Studio to integrate this.

Ngrok Extensions

With Ngrok Extension we only open our Visual Studio solution and navigate to Tool>Start ngrok Tunnel and it will create a tunnel for the websites under your solution.

Try it now!

God Bless!

Thanks,
Thomie

Ngrok – Free Web Tunneling

In the verge of today’s web development we encounter cases that in order to proceed we need to have a public accessible URL. Thankfully, Ngrok provide a free service to do this.

What it does is tunnel your machine to a Ngrok URL with a specific port. We just need to download the ngrok.exe from their website and run the command like

ngrok http 80


With this command your service on your local machine that is running on port 80 will be mapped and accessible publicly for FREE. For a full documentation view it here.

God Bless!

Thanks,
Thomie

Review: Tab Manager

In a world of development cycle we open several tabs for research and development, requirement gathering, and even when presenting. In cases like this we want to open tabs simultaneously. Most of us will do this by creating folder on our Bookmarks and open them up. For me I use Tab Manager on chrome to do this. Its so easy.

  1. Open the tabs you want
  2. Name them on Tab Manager
  3. Then click the + sign

Thats it. It will save that as a group and with just one click you will open them all. The best part of it is its free and it sync the data along with your google account. Download it now at https://chrome.google.com/webstore/detail/tab-manager/mcidendbndlekegaphipeeoaemckemhm

God Bless!

Thanks,
Thomie

Fix SignalR OnDisconnected not working

This just come up and after searching and testing it like to Fix SignalR OnDisconnected if not working is to implement on the client at least one method so that this method will be called. Think of it like a requirement.

Example for the SignalR residing on the same server

<!– Reference to jQuery –>
<!– Reference to SignalR –>
<script src=”~/hubs/signalr“></script>
<script>
var onlineHubProxy = $.connection.onlineHub;

onlineHubProxy.client.void = function(){
//do nothing
};

$.connection.start();

</script>

Then try again now and the Default methods of hubs will now be working properly.

God Bless!

Thanks,
Thomie

DateTime not parsing MM/dd/yyyy correctly on Windows 10 on ASP .Net MVC

Have you experienced coding and all of a sudden when on windows 10 you experienced that MM/dd/yyyy is not a valid date? This is because of the culture that is default implemented on your device, in this case on my device with Windows 10 Pro. To cause of this is the machine is by default is using dd/MM/yyyy and in this case apps that we are developing is having this kind of issue.

Thank fully the fastest way to fix is via the web.config with the following code:

<system.web>

<globalization culture=”en-US” uiCulture=”en-US”/>

 

And then run again your application and it will now accept your MM/dd/yyyy.

Replace words on MS Word using C#

Hi,

Recently I was instructed to create an application that will be able to replace an array of words and replace them with an array of corresponding words on an MS Word document. With this I’ve searched the following:

Prerequisites

  1. Visual Stduio
  2. Install the nuget package DocX
  3. Administrative access on the context the application is running

Code

Dictionary<string, string> lReplacements = new Dictionary<string, string>();
string newFullPath = @”c:\sample.docx”;

using (DocX document = DocX.Load(newFullPath))
{

//for loop is better than foreach
foreach (var item in lReplacements)
{

document.ReplaceText(item.Key, item.Value);

}
document.Save();

}

Hope it helped you as it helped me with this simple snippet.

God Bless!
Thanks,
Thomie

C# Task<object> return Type

In every signalr or webapi request based application there is a need to indicate the return type of Task<object> along with the async keyword. Let say this sample:

public async Task<MyObject> GetItem(){

MyObject myObject = new MyObject();

myObject = await getSomeWhereThere();

#doSomethingElse

return myObject;

}

In this sample, we all know that this is a asynchronous request from somewhere. Which dictates that myObject will return later after the getSomeWhereThere(); has finished executing. But we need to remind of a very important thing that #doSomethingElse will not be executed in Xamarin if it is not properly used. Let say we did this instead:

public async void GetItem(){

MyObject myObject = new MyObject();

myObject = await getSomeWhereThere();

#doSomethingElse

}

In this code the #doSomethingElse will not be executed because it will only assume that after the getSomeWhereThere(); is executed you don’t mind if #doSomethingElse is still needed. Thus make sure that we use the Task<MyObject> in cases like this so that #doSomethingElse will still be executed.

Tip: View your website from different countries

Hi,

May be your a developer that wanted to view your website from different countries. Yes in instance of DNS migration or just for the purpose of other troubleshooting needs. Then go visit LocaBrowser which enable you to visit your website in a max of 6 destination. Go there now http://www.locabrowser.com/

 

screenshot-324

God Bless!

Thanks,
Thomie

Reapply jQuery validate to a Form loaded via AJAX

Here is a quick snippet to apply jQuery validate to a form loaded via AJAX.

 

var form = $(“#youFormIdentifier”);
form.removeData(‘validator’);
form.removeData(‘unobtrusiveValidation’);
$.validator.unobtrusive.parse(form);

 

Then you can now check if it is valid via:

 

var isValid = form.valid();

Convert.ToDateTime Regardless of Culture

Did you upgrade to Windows 10 recently and your MVC website now have an issue under the development phase after it? Then maybe you also experience the same issue that affected your code on IIS. That is becuase Convert.ToDateTime utilizes the machine’s Culture(It changes when you use Windows 10 even you are using the same Country set) to parse a Date time. So to use it regardless of the Culture use the code snippet below.

 

string s = “20.09.2015 10.16.12”;
string expextedFormat = “dd.MM.yyyy HH.mm.ss”;
DateTime d;
bool isValid = DateTime.TryParseExact(s, expextedFormat , CultureInfo.InvariantCulture, DateTimeStyles.None, out d);

 

Hope it helped you as it helped me.

Service Oriented Architecture

Service Oriented Architecture is an architecture that make all request bounded on a form of a Service such as APIs. It consist of three different layers as follows:

  • Authorization Server – Responsible on Authorizing and Authenticating Users and encapsulate it on a token.
  • Resource Server – Responsible to give data based on the token that will be given by the Authorization server.
  • Clients – Responsible to request the token on behalf of a user from the Authorization Server and request resources from the Resource Server.

With this kind of architecture developer can make their application compatible to different platform such as Windows, Linux, and Mac OS. Some implementation of this uses some protocols such as OAuth which is implemented in different ways.

Signalr – OnDisconnect(bool stopCalled)

Most of us who are using .Net as our Programming language use Signalr as our Real-Time Framework. And we implement OnDisconnect in most cases to catch clients that have been disconnected. Since then there were no parameter included as an Overload of the said method. Lately on the latest releases by the Signalr team they have included an Overload so that we can distinguish what triggers the disconnection and help us manage our Apps behavior to it.

With this said I have one experience that I want to share as this may also frustrate some people who are counting connected users and having a problem that when their app have multi workers (Web Garden) they app somehow always trigger OnDisconnect even if the user is still connect. So I want to share this findings on how to properly address it.

  1. Make sure that the App is using a Backplane to manage connection on your hub so that the connections are shared on all threads/servers. I use SQLServer.
  2. Make sure to use the Database on counting your list of connection and tagging who is who. Because in memory List even its static will not be shared on a different server (obviously).
  3. Make sure to trigger disconnection action when the OnDisconnect is called with the stopCalled is equal to true.

Let me highlight what is stopCalled is equal to true means.

  1. It returns true if the method on the connection to close is trigger
  2. It returns true if the browser is called
  3. It returns false if the timeout has been met

Hope this instructions will help you manage your site as it help me on our projects.

God Bless!

Thanks,
Thomie

Regular Expression Online Tool

Regular Expression Online Tool

Do you have some regular expression that you want to test online? Then this online tool is for you,

First you will fill up the regular expression and then you will be given two textbox to test it. Thats it.

 

Regular Expression Online Tool

Regular Expression Online Tool

 

Regular Expression Online Tool Link : http://tools.netshiftmedia.com/regexlibrary/

Source Control with SVN Server

Hi There

It is a best practice to make your project versionized and in control. So I have look unto having a cost efficient way of controlling your code both Microsoft Project and PHP without having to think about licensing and making your project public on Github. Thus Setting up a Source Control with SVN Server will do the trick.

So here are the tools that you may use and I assume that you are using Windows 32/64-Bit as your Platform

  1. Subversion Edge by CollabNet This needs registration but its worth it as its all in one Server (APACHE + SVN Server + Https)
  2. Turtoise SVN This will serve as your client application that will integrate Context Menu Source control
  3. Internet Connection with Static IP (You can get it with some DSL Business Plan)

 That’s it you may want to Look on the given site as they are easy to follow.

Thanks,
Thomie 

Free ASP .NET Hosting

Hi There,

I have been wondering if there are any free ASP.NET hosting. This is best suites to students that needs to have this hosting to either their assignments, projects, or even thesis. Just a note that if there is FREE in a hosting there for they have limitations. So here goes:

  1. https://somee.com/FreeAspNetHosting.aspx
    1. Forced Advertisement
    2. Storage: 150MB
    3. Monthly transfer: 5GB/Month
    4. Web Domain: 1
    5. ASP .NET v1.1-4.0
    6. AJAX v1.0,3.5
    7. Silver Light
    8. MS Access 2003&2007
    9. 1 Mail domain Forwarder
    10. MS SQL(2003,2008,2012): 15MB

Still looking for other option. Will update you soon.

ASP Classic Show Their Error Message

Hi There!

Have you get a notifications when ever you experience an error on your script. Especially when you getthe error message:

An error occurred on the server when processing the URL. Please contact the system administrator

If you are developing ASP Classic in IIS 7.+ make sure that your ASP Classic show their error message and not the message above. This will help you in your development especially when an error occurs. This same situation happen to us when developing the said Scripting Language and IIS 7.+ default its error showing message to false. To modify this just follow this steps:

  1. Go to your IIS Manger.
  2. Select the ASP Icon.
  3. Under the Compilation Table open the Debugging Properties
  4. Make the Send Errors to Browser to TRUE
 
 

Creating a file to Download dynamically in an https / SSL connection

Hi there, 

Here is a tip when you are programming something that you want your file’s path to be hidden. It’s specially when its under a secure connection or https or SSL connection.

  1. Remember the mime type ea. image/jpg
  2. Remember the file name ea. image.jpg
  3. Remember not to put expiration and no-cache on your header
  4. Remember to open it on another tab or window as much as possible
  5. When you are debugging you can remove the headers so the file won’t be downloaded

Hope this tips can help you specially #3 because your download will fail on lower version of IE.

Thanks,