I'm trying to display an image using Lightbox with the logic something like this:
public ActionResult displayImg()
string lbx = "";
return View (lbx);
But it gives an error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Illegal characters in path.
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.ArgumentException: Illegal characters in path.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
You're passing <a ...></a> as a view name, which is translated into a filename in your project.
That's not a valid filename.
You probably want to return Content(...), which returns a literal string.
You also need to map the path using the URL class.
Related
the topic error showing me when I am redirect the view page from controller.
Here is the full error
An unhandled exception occurred while processing the request.
InvalidOperationException: The view '~/Views/Udhyog/Services.cshtml' was not found. The following locations were searched:
~/Views/Udhyog/Services.cshtml
Here is my controller code
public virtual IActionResult Index()
{
return View("~/Views/Udhyog/Services.cshtml");
}
I am surprised that why this type of error is showing, because In views => Udhyog named one folder and in that I want to show the services.cshtml view page.
So, is there my code wrong or is there any another method to redirect the view page?
return View("../UdhyogMaster/Services");
I have a MVC Project Which I want to Publish and upload it
I asked the server provider to upload my data base.
My Data base is local
and here is the information of this:
Name : vidiaweb_com_TourDbContext
DataBase: vidiaweb_com_TourDbContext-20160613111028
and here is my connection string
<connectionStrings>
<add name="vidiaweb_com_TourDbContext" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\vidiaweb_com_TourDbContext-20160613111028.mdf;Initial Catalog=vidiaweb_com_TourDbContext-20160613111028;Integrated Security=True;User Id=vidiaweb_com_TourDbContext;Password=password;" providerName="System.Data.SqlClient" />
</connectionStrings>
but in each page Which there is model for example like this
#model IEnumerable<vidiaweb_com.Models.Country>
, an error appeared:
'Server Error in '/' Application.
The system cannot find the file specified
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.ComponentModel.Win32Exception: The system cannot find the file specified
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): The system cannot find the file specified] '
Dose any one have any idea what may would be the problem?
Obviously, your web host is not putting the database in the /App_Data/ directory of your web site, which is what you are specifying in the connection string with |DataDirectory|\. It is likely being attached to a real SQL Server instance, in which case you won't specify a directory.
You need to obtain the server details of the database from your web host. Most likely your connection string will look something like this:
SERVER=data.somewhere.com;DATABASE=vidiaweb_com_TourDbContext;UID=TheApplicationUserName;PWD=TheApplicationPassword;
See ConnectionStrings.com for some more samples of what the connection string could look like.
I'm trying Windows Azure to host an MVC4 web application.
I've created a test app, using VS2012 MVC4 internet application template and added a custom Model and Controller to it.
I've published it on Azure and managed to get 'update-database' apply migrations to the Azure Database.
When i try the app locally, but using the Azure SQL database, it works fine.
I can login/register and use my test controller.
When i try the app online, i can use the test controller but login or register links give the following exception:
Server Error in '/' Application.
The "WebSecurity.InitializeDatabaseConnection" method can be called only once.
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.InvalidOperationException: The "WebSecurity.InitializeDatabaseConnection" method can be called only once.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The "WebSecurity.InitializeDatabaseConnection" method can be called only once.]
WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +123
WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +52
MembershipTest2.Filters.SimpleMembershipInitializer..ctor() +193
Do you have any idea where that comes from ?
If i debug (the local version), this method is only called once.
Thanks.
You could try encapsulating the call(s) to that method to ensure it's not called more then once
if (!WebMatrix.WebData.WebSecurity.Initialized)
{
WebSecurity.InitializeDatabaseConnection(...);
}
in my case I had both
(in web.config)
<add key="enableSimpleMembership" value="true" />
and
(in _ViewStart.cshtml)
WebSecurity.InitializeDatabaseConnection("club", "Account", "UserID", "UserName", autoCreateTables: true);
Solution: it seems you cannot have both, so remove one
Does the following SO discussion help you?
Cannot seed Users & Roles
I did find the following article helped me lot to use newer MVC4 & EF together with Simple Membership Provider so if you haven't read it please take a look:
SimpleMembership, Membership Providers, Universal Providers and the new ASP.NET 4.5 Web Forms and ASP.NET MVC 4 templates
I have the following code that retrieves a link to the latest post from the blog subsite:
XDocument doc = XDocument.Load("http://www.mysite.com/blog/syndication.axd");
XElement node = doc.Descendants("item").FirstOrDefault();
string text = node.Element("title").Value;
string uri = node.Element("link").Value;
The code always worked fine. This week I added ELMAH.MVC via NuGet as a Package Reference. As soon as I deploy the web.config file with the added ELMAH sections, I get the following error:
System.Web.HttpException (0x80004005): Error executing child request for handler
'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.
---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
If I put the old web.config file back, the error goes away.
Any idea why adding ELMAH would cause XDocument.Load to fail?
You need to look at your ASP.Net site and find the server-side error.
i have deployed an asp.net mvc site a few days ago and everything is going fine. I just deployed a second website (totally unrelated)
i just went to the first website and i am now getting an error below. Can anyone help me determine what is going on. I dont understand why they would know anything about each other.
The controller name 'Home' is ambiguous between the following types:
Site.netmvc.Controllers.HomeController
SalemGolf.Controllers.HomeController
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.InvalidOperationException: The controller name 'Home' is ambiguous between the following types:
Site.netmvc.Controllers.HomeController
SalemGolf.Controllers.HomeController
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The controller name 'Home' is ambiguous between the following types:
Site.netmvc.Controllers.HomeController
SalemGolf.Controllers.HomeController]
System.Web.Mvc.DefaultControllerFactory.GetControllerTypeWithinNamespaces(String controllerName, HashSet`1 namespaces) +417
System.Web.Mvc.DefaultControllerFactory.GetControllerType(String controllerName) +286
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +57
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase h
Make sure you don't have the assembly of the other site in your Bin directory.