Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Thursday, January 1, 2015

DNN Custom Error Pages

[Custom Errors] 

Default error pages may expose a lot of information, Like the language and the server you use, and such Info. could be used by malicious users to attack your site and your server.

Also default error pages look very ugly and outdated design, which may harm your brand.

So It's always recommended to use custom error pages..

So, How Could I display a custom error page in DNN when error occurs ?

To Disable DNN Error Handling, and Let Errors Bubble..
Host Settings >> Appearance >> Un-Check "Use Custom Error Messages? "


To Redirect Users To, Can be aspx page, but I prefer HTML
Then Create HTML Page at the root with Style


Then in Enable CustomErrors in Web.Config :
    <customErrors mode="On">
      <error statusCode="500" redirect="/MyCustomError.html"/>
      <error statusCode="404" redirect="/MyCustomError.html"/>
      <error statusCode="403" redirect="/MyCustomError.html"/>
    </customErrors>
  
Also You can Override IIS Error Pages and Redirect to your Custom Error Pages using the below web.config snippet

    <httpErrors>
      <remove statusCode="404" subStatusCode="-1"/>
      <error statusCode="404" prefixLanguageFilePath="" path="/MyCustomError.aspx" responseMode="ExecuteURL"/>
      <remove statusCode="403" subStatusCode="-1"/>
      <error statusCode="403" prefixLanguageFilePath="" path="/MyCustomError.html" responseMode="ExecuteURL"/>
    </httpErrors>

Tuesday, October 8, 2013

Post to twitter programatically with 3 lines of Code!

  1. Create a new web application
  2. using Nuget manager, download/install Tweetsharp
  3. Create a twitter application by visiting https://dev.twitter.com/apps/new
  4. Go to your twitter app settings, and make sure it's a read/write app
  5. Go to "Reset Keys" tab and reset keys, so the permission of read/write works with the new keys
  6. Generate Access Token and the first tab in your twitter settings
  7. Write the following Code, *Replace Dashes with your app keys, from the previous steps
======================================
using TweetSharp;
        //Store Keys
        string consumerKey = "-------";
        string consumerSecret = "-------";
        string accessToken = "-------";
        string accessTokenSecret = "-------";
        //Authenticate with twitter as your app.
        var service = new TwitterService(consumerKey, consumerSecret);
        service.AuthenticateWith(accessToken, accessTokenSecret);
        //Post Tweet
        var status = service.SendTweet(new SendTweetOptions { Status = "My Second #Tweet from Code :D" });
======================================
-- You can use the status variable to know the id of you posted status etc.

Sunday, March 31, 2013

Less for Dot Net - Asp.net

Introduction

Just hit an interesting utility, LESS Compiler for .net (asp.net)
So you can leverage the power of less (Dynamic CSS) in your .net web applications

Usage

Just add the following to the Web.config
<add type="dotless.Core.LessCssHttpHandler,dotless.Core" validate="false" path="*.LESS" verb="*" />
<section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler,dotless.Core" />
 
So, now you added a handler for .less files
 
Then configure it
<dotless minifyCss="false"
 cache="true" />   

*You can also use it from the code
Less.Parse("div { width: 1 + 1 }");
which will produce 
div {
  width: 2;
}
 

More Here
http://www.dotlesscss.org/

Wednesday, March 27, 2013

Why to use Sharepoint - Sharepoint Features Advantages and Disadvantages

Introduction

Actually this is just personal opinion about sharepoint, and I'll update it periodically with any new discoveries

I started to use sharepoint some months ago ..
So Not all things mentioned here are professional opinion, So feel free to discuss with me your opinions .

Sharepoint Advantages

  • Extreme Integration with other Microsoft products, like Lync, Outlook and Office suite etc.
     
    So you can integrate sharepoint site easily with outlook in minutes and login with windows accounts, using active directory of course .
    We can discuss integration capabilities later, if you want ...
  • Very useful for intranets due to its massive integration capabilities 
  • Many out of the box features like polls, discussions etc.

Sharepoint Disadvantages 

  • Very Heavy (Not very good in performance)
  • Requires Massive Hardware architecture (Server Farm)
  • Doesn't play well with all browsers, but it's improving with new versions

Share you ideas and opinions with me ...