make iframe height dynamic based on content inside- JQUERY/Javascript

You can retrieve the height of the IFRAME‘s content by using: contentWindow.document.body.scrollHeight After the IFRAME is loaded, you can then change the height by doing the following: <script type=”text/javascript”> function iframeLoaded() { var iFrameID = document.getElementById(‘idIframe’); if(iFrameID) { // here you can make the height, I delete it first, then I make it again iFrameID.height … Read more

.NET – Get protocol, host, and port

Even though @Rick has the accepted answer for this question, there’s actually a shorter way to do this, using the poorly named Uri.GetLeftPart() method. Uri url = new Uri(“http://www.mywebsite.com:80/pages/page1.aspx”); string output = url.GetLeftPart(UriPartial.Authority); There is one catch to GetLeftPart(), however. If the port is the default port for the scheme, it will strip it out. … Read more

Serving favicon.ico in ASP.NET MVC

I agree with the answer from Chris, but seeing this is a specific ASP.NET MVC question it would be better to use either Razor syntax: <link rel=”icon” href=”https://stackoverflow.com/questions/487230/@Url.Content(“~/content/favicon.ico”)”/> Or traditionally <link rel=”icon” href=”https://stackoverflow.com/questions/487230/<%= Url.Content(“~/content/favicon.ico”) %>”/> rather than <link rel=”icon” href=”http://www.mydomain.com/content/favicon.ico”/>

How to make custom error pages work in ASP.NET MVC 4

My current setup (on MVC3, but I think it still applies) relies on having an ErrorController, so I use: <system.web> <customErrors mode=”On” defaultRedirect=”~/Error”> <error redirect=”~/Error/NotFound” statusCode=”404″ /> </customErrors> </system.web> And the controller contains the following: public class ErrorController : Controller { public ViewResult Index() { return View(“Error”); } public ViewResult NotFound() { Response.StatusCode = 404; … Read more

Could not load file or assembly ‘Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’

In package manager console execute: Update-Package –reinstall Newtonsoft.Json. UPDATE I originally posted this as a comment but as @OwenBlacker suggested I’ll just put it here: If you still get an error after doing this, then what worked for me eventually is that I deleted Json.Net’s <dependentAssembly> section from my .config file. Reinstall brings it back … Read more

How can I solve a connection pool problem between ASP.NET and SQL Server?

In most cases connection pooling problems are related to connection leaks. Your application probably doesn’t close its database connections correctly and consistently. When you leave connections open, they remain blocked until the .NET garbage collector closes them for you by calling their Finalize() method. You want to make sure that you are really closing the … Read more

Display a view from another controller in ASP.NET MVC

Yes. By default, ASP.NET MVC checks first in \Views\[Controller_Dir]\, but after that, if it doesn’t find the view, it checks in \Views\Shared. The shared directory is there specifically to share Views across multiple controllers. Just add your View to the Shared subdirectory and you’re good to go. If you do return View(“~/Views/Wherever/SomeDir/MyView.aspx”) You can return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)