Posts

Node Js - Valid JSON body before it reaches API router endpoint "SyntaxError: Unexpected string in JSON at position 83
   at JSON.parse"

Image
When using node js with express, sometimes we get some unexpected errors from the API endpoint which doesn't really makes sense to the API consumer. On the other hand, we need to send appropriate message and Http Code to the consumer. If you pass invalid Json body to a node Js API, you may get the following enexpected error. " SyntaxError: Unexpected string in JSON at position 83 < br >  &nbsp; &nbsp;at JSON.parse" We can clearly see, such errors can't be handled accurately by the consumer application as it has lot of HTML data as response. To fix this, you can try to handle the parser error in the router endpoint and return apropriate message to the consumer, but there is an issue, the middleware itself returns the above error to the consumer, before it reaches the API end point. So, the solution is pretty simple and will be applicable to all the APIs. Write a middleware to handle this error like following. const app = express (); app. use (bodyParser.

Solved : 'WebApplication' does not contain a definition for 'UseKestrel' and the best extension method overload 'WebHostBuilder Kestrel Extensions.UseKestrel(IWebHostBuilder, Action)' requires a receiver of type 'IWebHostBuilder'

I had a requirement to upload files to .NET Core controller using Ajax call. Everything works well when the file size is < 30 Mb. When we try to upload larger files, the controller doesn't receive any files in the POST. Its always null. IList < IFormFile > files var file = Request.Form.Files[ 0 ]; All the values were null, I tried using Files as parameter to the post and also tried using " Request.Form ". After some research, I found that the upload limit of the Kestrel server need to be increased as it limits it by default set to 30 or 50 Mb(not very sure). When trying to add Kestrel  to the builder configuration, I was getting following error: "' WebApplication' does not contain a definition for 'UseKestrel' and the best extension method overload 'WebHostBuilder Kestrel Extensions.UseKestrel(IWebHostBuilder, Action<KestrelServerOptions>)' requires a receiver of type 'IWebHostBuilder '" SOLUTION: My .Net SDK vers

Visual Studio Build Issue : Build: 0 succeeded or up-to-date, 0 failed, 1 skipped

Image
"Unable to build or clean the solution in Visual Studio (applicable to almost all versions), output window message is : Build: 0 succeeded or up-to-date, 0 failed, 1 skipped". If you are facing the above issue, you are at the right place. Perhaps following can help you. BTW, the above image is self explanatory, let me still brief if in case the image is not getting downloaded on your Internet connection. In VS menu, go to Tools -> Options. Select -> Projects and Solutions -> Build and Run. Uncheck - "Only build startup projects and dependencies on Run." Your problem shall be resolved. Thank you for visitng my blog.

Visual Studio Build Error - The "GenerateResource" task failed unexpectedly

Error: "The GenerateResource task failed unexpectedly" This error is quite common while building the project in Visual Studio. This mainly occurs if the code has been copied from another location.  This solution is pretty simple. Locate and Open project folder -> obj -> Debug -> Delete content from this folder Try to build now, should be successful now.

SharePoint - Clear Timer Timer Cache / Clear Configuration Cache

Image
On number of occasions we may need to Clear SharePoint Configuration Cache, also known as SharePoint Timer Cache.  Let us consider one scenario; we have a SharePoint Farm with high availability (Streamlined topology with 4 Front End Web Servers), we want to change or reset Farm Passphrase. I changed the Passphrase successfully and now want to rejoin another Front End Webserver to the Farm which was disconnected earlier before resetting the Farm Passphrase. Note : To know how to change the SharePoint Passphrase, please visit my article  here . I tried to run the Configuration Wizard on the Front End Webserver for rejoining it to the Farm and after entering the new Passphrase it stops with error "Could not connect to the Configuration Database, make sure the Passphrase it correct".  To resolve this issue we need to clear the Configuration / Timer Cache from all the Servers on the SharePoint Farm, because the Farm is still using the Configuration Cache and we don

Reset your SharePoint Farm PassPhrase

If you forgot or missed or want to change your SharePoint Farm PassPhrase, here are the Powershell commands. $PassPhrase = ConvertTo-SecureString -String “yourNewFarmPassPhrase” -asPlainText -Force Set-SPPassPhrase -PassPhrase $PassPhrase -Confirm Note: Comfirm your new PassPhrase and you are Done. To make sure everything work perfectly after PassPhrase reset, you need to reset the Configuration / Timer Cache from all the Servers in the Farm. Please check my article for the same here .

SharePoint log error "Cannot find site lookup info for request Uri http://"

There are many reasons for which you can have this error in your SharePoint server logs. One of the scenerio is explained below. Main Reason: One of the major reason for this error is; the SharePoint is not able to resolve the URL. There is something wrong with the alternate access mapping. Please make sure the alternate access mapping is configured properly. For more details on alternate access mapping in SharePoint, please visit: Alternate Access Mapping We had sharepoint 2016 and all website under that were https:// from the firewall. When we tried to load the web site, error occured with a Correlation Id. After checking the code I found the error message "Cannot find site lookup info for request Uri http://". I URL was able to authenticate the user but on page load the error occurs. My alternate access mapping was: https://mysite                                         default                                               https://mysite