Category Archives: Programming

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.

Mediafire API for C# + Resharper

 Hi There,

I have been searching on the net of a Mediafire API for C#. I gently saw this API from Google. It has a note that it needs Resharper so I think you need that plugin before you can use it. As for the testing I don’t have any Resharper yet so I can test it myself so I have decided to publish it here so you can use and try it. You may give some feed back of your trying and share it to the world!

Source: http://pastebin.com/Cj1syDss

Mirror Download: Mediafire API C# + Resharper

Thanks,

 

Unfortunately I will not recommend dot.tk anymore.

Today 3/17/2014 again my tjsa.tk has been removed without any notices and worst of it all other domains I have has been remove. Unfortunately I will not recommend dot.tk anymore. Its a waste of time to follow up and even use it. Buy a domain instead.

Today 9/25/2012 I have successively get my tjsa.tk activated domain and back to my account!

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,

A potentially dangerous Request.Form value was detected from the client

Have you ever experience the following error in ASP .NET?

A potentially dangerous Request.Form value was detected from the client 

Then you are one like me. Then you should now that one of the values of your elements (<inputs> or <button> or <textarea>) has html elements on it. Example is bellow:

<input type=’text’ name=’content’ value='<script language=”javascript”>alert(“Hello World!”);</script>’/>

Then you should also know that this error is persisting because the values given above might be an XSS attack. If you are sure that you want to accept this type of values on your dabatase you may explicitly remove this validation by adding this tag to your page’s masterpage or 1st line of tag.

validateRequest=”false”

If you are on ASP .NET MVC you can add this to your model, assuming that your model has the content variable.

[AllowHtml]
public string content = String.Empty;

Thanks hope it help you allot. Also if you are not familiar with XSS attacks, I will try to make an article for that so you can create your own script that is hack-able, be able to prevent it, and know what are it’s crons.

God Bless!

jStorage:An alternative for Cookies

Have you ever wondered if there is an alternative for Cookies? 

You should, because there are limitation and downsides in using Cookies on your website that massively use this feature.

  1. Cookies has limited size on most browsers
  2. Cookies is transfer to server every page load
  3. If you overload the size of the Cookies it will also eat up the space of session and might remove it

Introducing jStorage, a jQuery way of saving your data to the local client and I quote

jStorage is a cross-browser key-value store database to store data locally in the browser – jStorage supports all major browsers, both in desktop (yes – even Internet Explorer 6) and in mobile.

Yes it even support IE 6!

So how to use it in an easy way?

  1. Include the following references to your project
    1. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
      <script src="https://raw.github.com/andris9/jStorage/master/jstorage.js"></script>
  2. Use $.jStorage.set(key, value) to save a value 
  3. Use $.jStorage.get(key, “default value”) to get a value

And thats it you are now using jStorage. 

Reference : http://www.jstorage.info/

WCF in Different Domain or Server

Hi There,

Its bean a while since I have updated my blog so I will be posting one of the things that I have experience on my work. That is WCF in Different Domain or Server. One of the main error that you may experience is the same as bellow:

Server Error in ‘/’ Application.


The request for security token could not be satisfied because authentication failed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ServiceModel.FaultException: The request for security token could not be satisfied because authentication failed.

Source Error:

Line 87:         
Line 88:         public bool IsExisting(string domain, string username) {
Line 89: return base.Channel.IsExisting(domain, username); Line 90:         }
Line 91:         


Source File: D:\Projects\MobileWeb\MobileWeb\Service References\SykesAD\Reference.cs Line: 89

Stack Trace:

[FaultException: The request for security token could not be satisfied because authentication failed.]
   System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(Message message, EndpointAddress target) +8904771
   System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState) +203

[SecurityNegotiationException: The caller was not authenticated by the service.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4729651
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725

 

This message or exeception happens in production (published files has been uploaded to IIS) and not when you are currently developing it on your Visual Studio. So what is the solution? Here is the simple solution that made me a little crazy upon gazing unto it.

//Let say here is your Instantiation of your WCF
ClassADClient ad = new ClassADClient();
//Then the solution is to add a credential that the system will use on using the said WCF
//Such as like this
ad.ClientCredentials.Windows.ClientCredential = new NetworkCredential(“domain\\username”, “password”);

That’s it thats the solution and you can now use the said service without the said error.

Hope I help you! 

 

Thanks,
Thomie Jose San Agustin, MCP 

IIS Missing ASP .Net 4.0 Pool

Have you’ve been missing some pool in your IIS for your ASP .Net?

The this article entitle IIS Missing ASP .Net 4.0 Pool will help you.

Chances are, you need to install .NET 4 (Which will also take care of a new AppPool for you)

  1. Open your command prompt (Windows + R) and type cmd and press ENTER
    You may need to start this as an administrator if you have UAC enabled.
    To do so, locate the exe (usually you can start typing with Start Menu open), right click and select “Run as Administrator”
  2. Type cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\ and press ENTER.
  3. Type aspnet_regiis.exe -ir and press ENTER again.
    • at this point you will see it begin working on installing .NET’s framework in to IIS for you
  4. Close the DOS prompt, re-open your start menu and right click Computer and select Manage
  5. Expand the left-hand side (Services and Applications) and select Internet Information Services
    • You’ll now have a new applet within the content window exclusively for IIS.
  6. Expand out your computer and locate the Application Pools node, and select it. (You should now see ASP.NET v4.0 listed)
  7. Expand out your Sites node and locate the site you want to modify (select it)
  8. To the right you’ll notice Basic Settings… just below the Edit Site text. Click this, and a new window should appear
  9. Select the .NET 4 AppPool using the Select… button and click ok.
  10. Restart the site, and you should be good-to-go.

(You can repeat steps 7-on for every site you want to apply .NET 4 on as well)

That’s it!

Thanks,
Thomie

Timezone your DateTime

Hi there!

I have been wondering today on how to make your website created on ASP .Net  perfect to all timezone so that if a user view your website on another country the date and time of your website is set to their timezone. So lets start to Timezone your DateTime!

  1. First create a Website Project on your Visual Studio
  2. Add Reference to this DateTimeW DLL
  3. On your website there should be an AJAX – Server Interaction. The AJAX will pass the timezone of the client to the Server and the server will fetch the timezone and set all your date.

For a clear way of implementing this your can download the demo below.

Demo TimezoneDatetime

jQuery Extension for ASP .Net MVC

My boss told us to search for a jQuery Extension for ASP .Net MVC to make the development easier. After minutes of searching the web I have found two extensions that you and I can use:

  1. DJME 2 which is an free and Open source
  2. Telerik Extensions for ASP .NET in this case is a paid extension

Both extensions utilizes the creation of custom helper to make jQuery development quite easier but abstracted. Abstracted because you are learning how the extensions should be use to produce jQuery but your not really coding jQuery. 

So in the end, I will still recommend using jQuery it self, doing all the hard works of creating the JavaScript file and code all the way, so you can produce the right jQuery output you have ever wanted.

ASP .Net MVC 3 – WebMail

Hi,

I have been searching the web on how to easily send email thru ASP .NET MVC 3 and finally found the right code for it, its called WebMail. Look at the code below and insert it to one of your Controller’s Action:

WebMail.SmtpServer = “smtp.gmail.com”;
WebMail.EnableSsl = true;
WebMail.SmtpPort = 25;
WebMail.UserName = “tjpublic1@gmail.com”;
WebMail.Password = “**********”;
WebMail.From = “tjpublic1@gmail.com”;
WebMail.Send(“********@******.com”, subject:”Subject”, body:”Message Here”);

Then try it on!

Its the Easiest Email on ASP .Net mvc 3 using webmail using gmail!

SQL Server Report Service

Time to remember an old friend on creating a report on ASP .Net, the Sql Server Report Service also known as SSRS. SSRS utilizes the MS SQL Server that simplifies the creation of report. The Concept is that you separate the location where your report is located so that even if your website is down you can still provide report and use it on other web programming language by putting it in an iFrame.

Upon reviewing here are the sites that made me remember:

In addition, SSRS need SQL Business Intelligence Development Studio (BIDS) in order to create reports and deploy directly these reports to the server.

ASP .Net MVC 3 File Upload

Doing File Upload in ASP .Net MVC 3 is easier than ASP .Net Web Form. On this example Only two controller and one view is needed to perform this task.

Controller

public class FileController : Controller
    {
        //
        // GET: /File/
 
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Upload(HttpPostedFileBase f)
        {
            if (f.ContentLength > 0)
            {
                string filePath = Path.Combine(HttpContext.Server.MapPath(“\\Uploads\\”), Path.GetFileName(f.FileName));
                f.SaveAs(filePath);                
            }
            return RedirectToAction(“Index”);
        }
 
    }
 
View
@{
    ViewBag.Title = “Index”;
}
 
<h2>Index</h2>
 
@using (Html.BeginForm(“Upload”, “File”, FormMethod.Post, new { enctype = “multipart/form-data” }))
{
    @Html.ValidationSummary(true)
 
    <input type=”file” name=”f” /><br />
    <input type=”submit” value=”Submit” />
}
 
Thats it. 
 
Download the source Here

public class FileController : Controller    {        //        // GET: /File/
        public ActionResult Index()        {            return View();        }        [HttpPost]        public ActionResult Upload(HttpPostedFileBase f)        {            if (f.ContentLength > 0)            {                string filePath = Path.Combine(HttpContext.Server.MapPath(“\\Uploads\\”), Path.GetFileName(f.FileName));                f.SaveAs(filePath);                            }            return RedirectToAction(“Index”);        }
    }

Get the User Referrer via JavaScript

Hi,

You van get the user referrer via javascript using the following code:

document.referrer

The said code will give you the full url path to which your user came from.

Example is http://google.com/?some-strings=goes-here

So you can check if its from a user from a google with a particular search string.

 

Just a Note. It can also received the same domain to which your site is in. For an instance your domain is http://domain.com then you referesh the page, the said code will return http://domain.com because you just refresh the page.